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.113 2015/05/01 00:39:44 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: 13 updated: 2015/04/26 18:06:58
1914 dnl -----------------
1915 dnl Tie together the configure-script macros for ncurses, preferring these in
1917 dnl a) ".pc" files for pkg-config, using $NCURSES_CONFIG_PKG
1918 dnl b) the "-config" script from ncurses, using $NCURSES_CONFIG
1919 dnl c) just plain libraries
1921 dnl $1 is the root library name (default: "ncurses")
1922 AC_DEFUN([CF_NCURSES_CONFIG],[
1923 AC_REQUIRE([CF_PKG_CONFIG])
1924 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1925 cf_have_ncuconfig=no
1927 if test "x$PKG_CONFIG" != xnone; then
1928 AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
1929 if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
1932 AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
1933 cf_have_ncuconfig=unknown
1935 cf_save_CPPFLAGS="$CPPFLAGS"
1936 cf_save_LIBS="$LIBS"
1938 CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
1939 CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
1941 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1942 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1943 [AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
1945 { char *xx = curses_version(); return (xx == 0); }],
1946 [cf_have_ncuconfig=yes],
1947 [cf_have_ncuconfig=no])],
1948 [cf_have_ncuconfig=no])
1950 AC_MSG_RESULT($cf_have_ncuconfig)
1951 if test "$cf_have_ncuconfig" != "yes"
1953 CPPFLAGS="$cf_save_CPPFLAGS"
1954 LIBS="$cf_save_LIBS"
1955 NCURSES_CONFIG_PKG=none
1957 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1958 NCURSES_CONFIG_PKG=$cf_ncuconfig_root
1963 NCURSES_CONFIG_PKG=none
1966 NCURSES_CONFIG_PKG=none
1969 if test "x$cf_have_ncuconfig" = "xno"; then
1970 echo "Looking for ${cf_ncuconfig_root}-config"
1972 CF_ACVERSION_CHECK(2.52,
1973 [AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
1974 [AC_PATH_PROGS(NCURSES_CONFIG, ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
1976 if test "$NCURSES_CONFIG" != none ; then
1978 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1979 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
1981 # even with config script, some packages use no-override for curses.h
1982 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
1984 dnl like CF_NCURSES_CPPFLAGS
1985 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1987 dnl like CF_NCURSES_LIBS
1988 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1989 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1991 dnl like CF_NCURSES_VERSION
1992 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1996 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1997 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2004 dnl ---------------------------------------------------------------------------
2005 dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
2006 dnl -------------------
2007 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2008 dnl the CPPFLAGS variable so we can include its header.
2010 dnl The header files may be installed as either curses.h, or ncurses.h (would
2011 dnl be obsolete, except that some packagers prefer this name to distinguish it
2012 dnl from a "native" curses implementation). If not installed for overwrite,
2013 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2014 dnl /usr/include/ncurses), but someone may have installed overwriting the
2015 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
2016 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2019 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2020 dnl is already in the include-path, don't even bother with this, since we cannot
2021 dnl easily determine which file it is. In this case, it has to be <curses.h>.
2023 dnl The optional parameter gives the root name of the library, in case it is
2024 dnl not installed as the default curses library. That is how the
2025 dnl wide-character version of ncurses is installed.
2026 AC_DEFUN([CF_NCURSES_CPPFLAGS],
2027 [AC_REQUIRE([CF_WITH_CURSES_DIR])
2029 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2030 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2032 test -n "$cf_cv_curses_dir" && \
2033 test "$cf_cv_curses_dir" != "no" && { \
2034 CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2037 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2038 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2039 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2040 for cf_header in $cf_header_list
2042 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2043 test "$cf_cv_ncurses_h" != no && break
2050 # some applications need this, but should check for NCURSES_VERSION
2051 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2055 dnl ---------------------------------------------------------------------------
2056 dnl CF_NCURSES_EXT_FUNCS version: 4 updated: 2012/10/06 16:39:58
2057 dnl --------------------
2058 dnl Since 2007/11/17, ncurses has defined NCURSES_EXT_FUNCS; earlier versions
2059 dnl may provide these functions. Define the symbol if it is not defined, and
2061 AC_DEFUN([CF_NCURSES_EXT_FUNCS],
2063 AC_CACHE_CHECK(for ncurses extended functions,cf_cv_ncurses_ext_funcs,[
2065 #include <${cf_cv_ncurses_header:-curses.h}>],
2067 int x = NCURSES_EXT_FUNCS
2068 ],[cf_cv_ncurses_ext_funcs=defined],[
2070 #include <${cf_cv_ncurses_header:-curses.h}>],
2072 (void) assume_default_colors (0, 0);
2073 (void) curses_version ();
2074 (void) define_key (0, 0);
2075 (void) is_term_resized (0, 0);
2076 (void) key_defined (0);
2077 (void) keybound (0, 0);
2078 (void) keyok (0, 0);
2079 (void) resize_term (0, 0);
2080 (void) resizeterm (0, 0);
2081 (void) use_default_colors ();
2082 (void) use_extended_names (0);
2083 (void) wresize (0, 0, 0);],
2084 [cf_cv_ncurses_ext_funcs=yes],
2085 [cf_cv_ncurses_ext_funcs=no])
2088 test "$cf_cv_ncurses_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS,1,[Define to 1 if we have ncurses extensions])
2090 dnl ---------------------------------------------------------------------------
2091 dnl CF_NCURSES_HEADER version: 4 updated: 2015/04/15 19:08:48
2092 dnl -----------------
2093 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2094 dnl variations of ncurses' installs.
2096 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2097 AC_DEFUN([CF_NCURSES_HEADER],[
2099 if test "$cf_cv_ncurses_h" != no ; then
2100 cf_cv_ncurses_header=$cf_cv_ncurses_h
2103 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2104 test -n "$verbose" && echo
2105 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2106 test -n "$verbose" && echo search path $cf_search
2107 cf_save2_CPPFLAGS="$CPPFLAGS"
2108 for cf_incdir in $cf_search
2110 CF_ADD_INCDIR($cf_incdir)
2115 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2116 if test "$cf_cv_ncurses_h2" != no ; then
2117 cf_cv_ncurses_h2=$cf_incdir/$cf_header
2118 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
2121 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2123 CPPFLAGS="$cf_save2_CPPFLAGS"
2124 test "$cf_cv_ncurses_h2" != no && break
2126 test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2129 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2130 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2131 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2132 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2134 CF_ADD_INCDIR($cf_1st_incdir)
2138 # Set definitions to allow ifdef'ing for ncurses.h
2140 case $cf_cv_ncurses_header in
2142 AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
2146 case $cf_cv_ncurses_header in
2147 (ncurses/curses.h|ncurses/ncurses.h)
2148 AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
2150 (ncursesw/curses.h|ncursesw/ncurses.h)
2151 AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2156 dnl ---------------------------------------------------------------------------
2157 dnl CF_NCURSES_LIBS version: 17 updated: 2015/04/15 19:08:48
2159 dnl Look for the ncurses library. This is a little complicated on Linux,
2160 dnl because it may be linked with the gpm (general purpose mouse) library.
2161 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2162 dnl unusable with ncurses. However, we don't want to link with gpm unless
2163 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2164 dnl and the linker will record a dependency.
2166 dnl The optional parameter gives the root name of the library, in case it is
2167 dnl not installed as the default curses library. That is how the
2168 dnl wide-character version of ncurses is installed.
2169 AC_DEFUN([CF_NCURSES_LIBS],
2170 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2172 cf_nculib_root=ifelse($1,,ncurses,$1)
2173 # This works, except for the special case where we find gpm, but
2174 # ncurses is in a nonstandard location via $LIBS, and we really want
2177 cf_ncurses_SAVE="$LIBS"
2178 AC_CHECK_LIB(gpm,Gpm_Open,
2179 [AC_CHECK_LIB(gpm,initscr,
2180 [LIBS="$cf_ncurses_SAVE"],
2181 [cf_ncurses_LIBS="-lgpm"])])
2185 # This is only necessary if you are linking against an obsolete
2186 # version of ncurses (but it should do no harm, since it's static).
2187 if test "$cf_nculib_root" = ncurses ; then
2188 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2193 CF_ADD_LIBS($cf_ncurses_LIBS)
2195 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2197 CF_ADD_LIBS(-l$cf_nculib_root)
2199 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2200 [#include <${cf_cv_ncurses_header:-curses.h}>],
2205 if test -n "$cf_ncurses_LIBS" ; then
2206 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2207 cf_ncurses_SAVE="$LIBS"
2208 for p in $cf_ncurses_LIBS ; do
2209 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2210 if test "$q" != "$LIBS" ; then
2214 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2215 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2216 [AC_MSG_RESULT(yes)],
2218 LIBS="$cf_ncurses_SAVE"])
2221 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2222 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2224 dnl ---------------------------------------------------------------------------
2225 dnl CF_NCURSES_VERSION version: 14 updated: 2012/10/06 08:57:51
2226 dnl ------------------
2227 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2228 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
2229 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2230 AC_DEFUN([CF_NCURSES_VERSION],
2232 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2233 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2234 cf_cv_ncurses_version=no
2238 #include <${cf_cv_ncurses_header:-curses.h}>
2242 FILE *fp = fopen("$cf_tempfile", "w");
2243 #ifdef NCURSES_VERSION
2244 # ifdef NCURSES_VERSION_PATCH
2245 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2247 fprintf(fp, "%s\n", NCURSES_VERSION);
2251 fprintf(fp, "old\n");
2256 ${cf_cv_main_return:-return}(0);
2258 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2260 # This will not work if the preprocessor splits the line after the
2261 # Autoconf token. The 'unproto' program does that.
2262 cat > conftest.$ac_ext <<EOF
2263 #include <${cf_cv_ncurses_header:-curses.h}>
2265 #ifdef NCURSES_VERSION
2266 Autoconf NCURSES_VERSION
2274 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2276 if test -f conftest.out ; then
2277 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2278 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2284 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2286 dnl ---------------------------------------------------------------------------
2287 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
2288 dnl ----------------------
2289 dnl Check for ncurses "wrap-prefix" used for public variables which have been
2290 dnl wrapped with a function to help with concurrency control.
2291 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
2293 AC_MSG_CHECKING(for ncurses wrap-prefix)
2294 AC_ARG_WITH(ncurses-wrap-prefix,
2295 [ --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
2296 [NCURSES_WRAP_PREFIX=$withval],
2297 [NCURSES_WRAP_PREFIX=_nc_])
2298 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
2300 AC_SUBST(NCURSES_WRAP_PREFIX)
2302 dnl ---------------------------------------------------------------------------
2303 dnl CF_NETBSD_FORM_H version: 2 updated: 2012/10/06 16:39:58
2304 dnl ----------------
2305 dnl Check for NetBSD's form.h, which is incompatible with SVr4 and ncurses.
2306 dnl Some workarounds are needed in client programs to allow them to compile.
2307 AC_DEFUN([CF_NETBSD_FORM_H],[
2308 AC_CACHE_CHECK(for NetBSD form.h,cf_cv_netbsd_form_h,[
2310 #include <${cf_cv_ncurses_header:-curses.h}>
2314 int y = current_field(form)->cursor_ypos;
2315 int x = current_field(form)->cursor_xpos;
2316 ],[cf_cv_netbsd_form_h=yes
2317 ],[cf_cv_netbsd_form_h=no])
2320 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])
2322 dnl ---------------------------------------------------------------------------
2323 dnl CF_NETBSD_MENU_H version: 2 updated: 2012/10/06 16:39:58
2324 dnl ----------------
2325 dnl Check for NetBSD's menu.h, which is incompatible with SVr4 and ncurses.
2326 dnl Some workarounds are needed in client programs to allow them to compile.
2327 AC_DEFUN([CF_NETBSD_MENU_H],[
2328 AC_CACHE_CHECK(for NetBSD menu.h,cf_cv_netbsd_menu_h,[
2330 #include <${cf_cv_ncurses_header:-curses.h}>
2334 int y = menu->max_item_width;
2335 ],[cf_cv_netbsd_menu_h=yes
2336 ],[cf_cv_netbsd_menu_h=no])
2339 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])
2341 dnl ---------------------------------------------------------------------------
2342 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
2343 dnl ------------------
2344 dnl see CF_WITH_NO_LEAKS
2345 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2346 AC_MSG_CHECKING(if you want to use $1 for testing)
2349 [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
2352 : ${with_cflags:=-g}
2353 : ${with_no_leaks:=yes}
2356 AC_MSG_RESULT(${with_$1:-no})
2358 case .$with_cflags in
2370 dnl ---------------------------------------------------------------------------
2371 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
2373 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
2374 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2375 dnl result begins with 'NONE'. This is necessary to work around autoconf's
2376 dnl delayed evaluation of those symbols.
2377 AC_DEFUN([CF_PATH_SYNTAX],[
2378 if test "x$prefix" != xNONE; then
2379 cf_path_syntax="$prefix"
2381 cf_path_syntax="$ac_default_prefix"
2385 (.\[$]\(*\)*|.\'*\'*)
2389 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
2391 (.\[$]{*prefix}*|.\[$]{*dir}*)
2395 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2400 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2403 ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2407 dnl ---------------------------------------------------------------------------
2408 dnl CF_PDCURSES_X11 version: 13 updated: 2012/10/06 16:39:58
2410 dnl Configure for PDCurses' X11 library
2411 AC_DEFUN([CF_PDCURSES_X11],[
2412 AC_REQUIRE([CF_X_ATHENA])
2414 CF_ACVERSION_CHECK(2.52,
2415 [AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
2416 [AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
2418 if test "$XCURSES_CONFIG" != none ; then
2420 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
2421 CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
2423 cf_cv_lib_XCurses=yes
2427 LDFLAGS="$LDFLAGS $X_LIBS"
2428 CF_CHECK_CFLAGS($X_CFLAGS)
2429 AC_CHECK_LIB(X11,XOpenDisplay,
2430 [CF_ADD_LIBS(-lX11)],,
2431 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
2432 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
2433 CF_ADD_LIBS(-lXCurses)
2435 #include <xcurses.h>
2436 char *XCursesProgramName = "test";
2438 [cf_cv_lib_XCurses=yes],
2439 [cf_cv_lib_XCurses=no])
2444 if test $cf_cv_lib_XCurses = yes ; then
2445 AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
2446 AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
2447 AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
2449 AC_MSG_ERROR(Cannot link with XCurses)
2452 dnl ---------------------------------------------------------------------------
2453 dnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
2455 dnl Check for the package-config program, unless disabled by command-line.
2456 AC_DEFUN([CF_PKG_CONFIG],
2458 AC_MSG_CHECKING(if you want to use pkg-config)
2459 AC_ARG_WITH(pkg-config,
2460 [ --with-pkg-config{=path} enable/disable use of pkg-config],
2461 [cf_pkg_config=$withval],
2462 [cf_pkg_config=yes])
2463 AC_MSG_RESULT($cf_pkg_config)
2465 case $cf_pkg_config in
2470 CF_ACVERSION_CHECK(2.52,
2471 [AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
2472 [AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
2479 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2480 if test "$PKG_CONFIG" != none ; then
2481 CF_PATH_SYNTAX(PKG_CONFIG)
2482 elif test "x$cf_pkg_config" != xno ; then
2483 AC_MSG_WARN(pkg-config is not installed)
2486 AC_SUBST(PKG_CONFIG)
2488 dnl ---------------------------------------------------------------------------
2489 dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
2490 dnl -----------------
2491 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2493 dnl POSIX.1-1990 _POSIX_SOURCE
2494 dnl POSIX.1-1990 and _POSIX_SOURCE and
2495 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
2497 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
2498 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
2499 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
2502 dnl $1 is the nominal value for _POSIX_C_SOURCE
2503 AC_DEFUN([CF_POSIX_C_SOURCE],
2505 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2507 cf_save_CFLAGS="$CFLAGS"
2508 cf_save_CPPFLAGS="$CPPFLAGS"
2510 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2511 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2513 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2514 CF_MSG_LOG(if the symbol is already defined go no further)
2515 AC_TRY_COMPILE([#include <sys/types.h>],[
2516 #ifndef _POSIX_C_SOURCE
2519 [cf_cv_posix_c_source=no],
2520 [cf_want_posix_source=no
2521 case .$cf_POSIX_C_SOURCE in
2523 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2526 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2527 cf_want_posix_source=yes
2530 cf_want_posix_source=yes
2533 if test "$cf_want_posix_source" = yes ; then
2534 AC_TRY_COMPILE([#include <sys/types.h>],[
2535 #ifdef _POSIX_SOURCE
2538 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2540 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2541 CFLAGS="$cf_trim_CFLAGS"
2542 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2543 CF_MSG_LOG(if the second compile does not leave our definition intact error)
2544 AC_TRY_COMPILE([#include <sys/types.h>],[
2545 #ifndef _POSIX_C_SOURCE
2548 [cf_cv_posix_c_source=no])
2549 CFLAGS="$cf_save_CFLAGS"
2550 CPPFLAGS="$cf_save_CPPFLAGS"
2554 if test "$cf_cv_posix_c_source" != no ; then
2555 CFLAGS="$cf_trim_CFLAGS"
2556 CPPFLAGS="$cf_trim_CPPFLAGS"
2557 CF_ADD_CFLAGS($cf_cv_posix_c_source)
2561 dnl ---------------------------------------------------------------------------
2562 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
2564 dnl Append definitions and rules for the given programs to the subdirectory
2565 dnl Makefiles, and the recursion rule for the top-level Makefile.
2568 dnl $1 = script to run
2569 dnl $2 = list of subdirectories
2573 AC_DEFUN([CF_PRG_RULES],
2577 if test ! -d $srcdir/$cf_dir; then
2579 elif test -f $srcdir/$cf_dir/programs; then
2580 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
2585 dnl ---------------------------------------------------------------------------
2586 dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
2588 dnl standard check for CC, plus followup sanity checks
2589 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
2590 AC_DEFUN([CF_PROG_CC],[
2591 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
2593 CF_ACVERSION_CHECK(2.52,
2598 dnl ---------------------------------------------------------------------------
2599 dnl CF_PROG_INSTALL version: 7 updated: 2015/04/18 08:56:57
2601 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
2602 dnl misc/tabset install won't work properly. Usually this happens only when
2603 dnl using the fallback mkinstalldirs script
2604 AC_DEFUN([CF_PROG_INSTALL],
2610 CF_DIRNAME(cf_dir,$INSTALL)
2611 test -z "$cf_dir" && cf_dir=.
2612 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
2616 dnl ---------------------------------------------------------------------------
2617 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
2619 AC_DEFUN([CF_PROG_LINT],
2621 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
2624 dnl ---------------------------------------------------------------------------
2625 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2626 dnl ----------------
2627 dnl Remove all -U and -D options that refer to the given symbol from a list
2628 dnl of C compiler options. This works around the problem that not all
2629 dnl compilers process -U and -D options from left-to-right, so a -U option
2630 dnl cannot be used to cancel the effect of a preceding -D option.
2632 dnl $1 = target (which could be the same as the source variable)
2633 dnl $2 = source (including '$')
2634 dnl $3 = symbol to remove
2635 define([CF_REMOVE_DEFINE],
2638 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
2639 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
2641 dnl ---------------------------------------------------------------------------
2642 dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
2644 AC_DEFUN([CF_RPATH_HACK],
2646 AC_REQUIRE([CF_LD_RPATH_OPT])
2647 AC_MSG_CHECKING(for updated LDFLAGS)
2648 if test -n "$LD_RPATH_OPT" ; then
2649 AC_MSG_RESULT(maybe)
2651 AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2652 cf_rpath_list="/usr/lib /lib"
2653 if test "$cf_ldd_prog" != no
2657 AC_TRY_LINK([#include <stdio.h>],
2659 [cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2660 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ ]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2662 # If we passed the link-test, but get a "not found" on a given library,
2663 # this could be due to inept reconfiguration of gcc to make it only
2664 # partly honor /usr/local/lib (or whatever). Sometimes this behavior
2665 # is intentional, e.g., installing gcc in /usr/bin and suppressing the
2666 # /usr/local libraries.
2667 if test -n "$cf_rpath_oops"
2669 for cf_rpath_src in $cf_rpath_oops
2671 for cf_rpath_dir in \
2676 if test -f $cf_rpath_dir/lib/$cf_rpath_src
2678 CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2679 LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2687 CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2689 CF_RPATH_HACK_2(LDFLAGS)
2690 CF_RPATH_HACK_2(LIBS)
2692 CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2696 AC_SUBST(EXTRA_LDFLAGS)
2698 dnl ---------------------------------------------------------------------------
2699 dnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
2701 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
2702 dnl EXTRA_LDFLAGS for each -L option found.
2704 dnl $cf_rpath_list contains a list of directories to ignore.
2706 dnl $1 = variable name to update. The LDFLAGS variable should be the only one,
2707 dnl but LIBS often has misplaced -L options.
2708 AC_DEFUN([CF_RPATH_HACK_2],
2710 CF_VERBOSE(...checking $1 [$]$1)
2713 for cf_rpath_src in [$]$1
2715 case $cf_rpath_src in
2718 # check if this refers to a directory which we will ignore
2720 if test -n "$cf_rpath_list"
2722 for cf_rpath_item in $cf_rpath_list
2724 if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2732 if test "$cf_rpath_skip" = no
2734 # transform the option
2735 if test "$LD_RPATH_OPT" = "-R " ; then
2736 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
2738 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2741 # if we have not already added this, add it now
2742 cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
2743 if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
2745 CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2746 EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2751 cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2755 CF_VERBOSE(...checked $1 [$]$1)
2756 AC_SUBST(EXTRA_LDFLAGS)
2758 dnl ---------------------------------------------------------------------------
2759 dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2761 dnl signal handler, but there are some gcc depedencies in that recommendation.
2763 AC_DEFUN([CF_SIG_ATOMIC_T],
2765 AC_MSG_CHECKING(for signal global datatype)
2766 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2768 "volatile sig_atomic_t" \
2773 #include <sys/types.h>
2779 static void handler(int sig)
2783 [signal(SIGINT, handler);
2785 [cf_cv_sig_atomic_t=$cf_type],
2786 [cf_cv_sig_atomic_t=no])
2787 test "$cf_cv_sig_atomic_t" != no && break
2790 AC_MSG_RESULT($cf_cv_sig_atomic_t)
2791 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2793 dnl ---------------------------------------------------------------------------
2794 dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
2796 dnl Construct a search-list for a nonstandard header/lib-file
2797 dnl $1 = the variable to return as result
2798 dnl $2 = the package name
2799 dnl $3 = the subdirectory, e.g., bin, include or lib
2800 AC_DEFUN([CF_SUBDIR_PATH],
2804 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
2806 for cf_subdir_prefix in \
2814 CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
2817 dnl ---------------------------------------------------------------------------
2818 dnl CF_SYS_TIME_SELECT version: 6 updated: 2015/04/18 08:56:57
2819 dnl ------------------
2820 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2821 dnl older SCO configurations.
2822 AC_DEFUN([CF_SYS_TIME_SELECT],
2824 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2825 AC_CACHE_VAL(cf_cv_sys_time_select,[
2827 #include <sys/types.h>
2828 #ifdef HAVE_SYS_TIME_H
2829 #include <sys/time.h>
2831 #ifdef HAVE_SYS_SELECT_H
2832 #include <sys/select.h>
2834 ],[],[cf_cv_sys_time_select=yes],
2835 [cf_cv_sys_time_select=no])
2837 AC_MSG_RESULT($cf_cv_sys_time_select)
2838 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>])
2840 dnl ---------------------------------------------------------------------------
2841 dnl CF_TERM_HEADER version: 4 updated: 2015/04/15 19:08:48
2843 dnl Look for term.h, which is part of X/Open curses. It defines the interface
2844 dnl to terminfo database. Usually it is in the same include-path as curses.h,
2845 dnl but some packagers change this, breaking various applications.
2846 AC_DEFUN([CF_TERM_HEADER],[
2847 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2848 case ${cf_cv_ncurses_header} in
2849 (*/ncurses.h|*/ncursesw.h)
2850 cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2853 cf_term_header=term.h
2857 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2859 AC_TRY_COMPILE([#include <stdio.h>
2860 #include <${cf_cv_ncurses_header:-curses.h}>
2862 ],[int x = auto_left_margin],[
2863 cf_cv_term_header="$cf_test"],[
2864 cf_cv_term_header=unknown
2866 test "$cf_cv_term_header" != unknown && break
2870 # Set definitions to allow ifdef'ing to accommodate subdirectories
2872 case $cf_cv_term_header in
2874 AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
2878 case $cf_cv_term_header in
2880 AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
2883 AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
2887 dnl ---------------------------------------------------------------------------
2888 dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
2890 dnl Define a top_builddir symbol, for applications that need an absolute path.
2891 AC_DEFUN([CF_TOP_BUILDDIR],
2893 top_builddir=ifelse($1,,`pwd`,$1)
2894 AC_SUBST(top_builddir)
2896 dnl ---------------------------------------------------------------------------
2897 dnl CF_TPUTS_PROTO version: 3 updated: 2015/04/17 21:26:14
2899 dnl Check for type of function-pointer passed to tputs. Some old
2900 dnl implementations used functions that had different prototypes, making it
2901 dnl hard to compile portable programs using tputs.
2902 AC_DEFUN([CF_TPUTS_PROTO],[
2903 CF_CURSES_FUNCS(tputs)
2904 if test x$cf_cv_func_tputs = xyes
2907 for cf_arg in int char
2909 for cf_ret in int void
2911 if test $cf_ret = void
2913 cf_return="/* nothing */"
2915 cf_return="return value"
2918 #include <${cf_cv_ncurses_header:-curses.h}>
2919 #include <$cf_cv_term_header>
2921 static $cf_ret outc($cf_arg value) { $cf_return; }
2923 tputs("hello", 0, outc);
2924 ${cf_cv_main_return:-return}(0);
2926 CF_VERBOSE([prototype $cf_ret func($cf_arg value)])
2927 cat >>confdefs.h <<EOF
2928 #define TPUTS_ARG $cf_arg
2929 #define TPUTS_PROTO(func,value) $cf_ret func(TPUTS_ARG value)
2930 #define TPUTS_RETURN(value) $cf_return
2936 test $cf_done = yes && break
2940 dnl ---------------------------------------------------------------------------
2941 dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
2943 dnl Trim extra base X libraries added as a workaround for inconsistent library
2944 dnl dependencies returned by "new" pkg-config files.
2945 AC_DEFUN([CF_TRIM_X_LIBS],[
2946 for cf_trim_lib in Xmu Xt X11
2949 (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
2950 LIBS=`echo "$LIBS " | sed -e 's/ / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
2951 CF_VERBOSE(..trimmed $LIBS)
2956 dnl ---------------------------------------------------------------------------
2957 dnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
2958 dnl -----------------
2959 dnl This is a simple wrapper to use for pkg-config, for libraries which may be
2960 dnl available in that form.
2962 dnl $1 = package name
2963 dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
2964 dnl $3 = logic to use if pkg-config does not have the package
2965 AC_DEFUN([CF_TRY_PKG_CONFIG],[
2966 AC_REQUIRE([CF_PKG_CONFIG])
2968 if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
2969 CF_VERBOSE(found package $1)
2970 cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
2971 cf_pkgconfig_libs="`$PKG_CONFIG --libs $1 2>/dev/null`"
2972 CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
2973 CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
2974 CF_ADD_CFLAGS($cf_pkgconfig_incs)
2975 CF_ADD_LIBS($cf_pkgconfig_libs)
2976 ifelse([$2],,:,[$2])
2980 ifelse([$3],,:,[$3])
2983 dnl ---------------------------------------------------------------------------
2984 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
2985 dnl -------------------
2986 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
2987 dnl can define it successfully.
2988 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
2989 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2993 #include <sys/types.h>
2995 #ifndef _XOPEN_SOURCE
2998 [cf_cv_xopen_source=no],
2999 [cf_save="$CPPFLAGS"
3000 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3004 #include <sys/types.h>
3006 #ifdef _XOPEN_SOURCE
3009 [cf_cv_xopen_source=no],
3010 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3015 if test "$cf_cv_xopen_source" != no ; then
3016 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3017 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3018 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3019 CF_ADD_CFLAGS($cf_temp_xopen_source)
3022 dnl ---------------------------------------------------------------------------
3023 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3025 dnl Make an uppercase version of a variable
3026 dnl $1=uppercase($2)
3027 AC_DEFUN([CF_UPPER],
3029 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3031 dnl ---------------------------------------------------------------------------
3032 dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
3034 dnl Check for multibyte support, and if not found, utf8 compatibility library
3035 AC_DEFUN([CF_UTF8_LIB],
3037 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3038 cf_save_LIBS="$LIBS"
3040 #include <stdlib.h>],[putwc(0,0);],
3041 [cf_cv_utf8_lib=yes],
3043 #include <libutf8.h>],[putwc(0,0);],utf8,
3044 [cf_cv_utf8_lib=add-on],
3045 [cf_cv_utf8_lib=no])
3048 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3050 if test "$cf_cv_utf8_lib" = "add-on" ; then
3051 AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
3052 CF_ADD_INCDIR($cf_cv_header_path_utf8)
3053 CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3054 CF_ADD_LIBS($cf_cv_library_file_utf8)
3057 dnl ---------------------------------------------------------------------------
3058 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3060 dnl Use AC_VERBOSE w/o the warnings
3061 AC_DEFUN([CF_VERBOSE],
3062 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
3065 dnl ---------------------------------------------------------------------------
3066 dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
3068 dnl Check if type wide-character type $1 is declared, and if so, which header
3069 dnl file is needed. The second parameter is used to set a shell variable when
3070 dnl the type is not found. The first parameter sets a shell variable for the
3072 AC_DEFUN([CF_WCHAR_TYPE],
3074 # This is needed on Tru64 5.0 to declare $1
3075 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
3080 #ifdef HAVE_LIBUTF8_H
3081 #include <libutf8.h>
3090 #ifdef HAVE_LIBUTF8_H
3091 #include <libutf8.h>
3095 [cf_cv_$1=unknown])])])
3097 if test "$cf_cv_$1" = yes ; then
3098 AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
3103 # if we do not find $1 in either place, use substitution to provide a fallback.
3104 if test "$cf_cv_$1" = unknown ; then
3109 # if we find $1 in either place, use substitution to provide a fallback.
3110 if test "$cf_cv_$1" != unknown ; then
3115 dnl ---------------------------------------------------------------------------
3116 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
3117 dnl ------------------
3118 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3120 AC_DEFUN([CF_WITH_CURSES_DIR],[
3122 AC_MSG_CHECKING(for specific curses-directory)
3123 AC_ARG_WITH(curses-dir,
3124 [ --with-curses-dir=DIR directory in which (n)curses is installed],
3125 [cf_cv_curses_dir=$withval],
3126 [cf_cv_curses_dir=no])
3127 AC_MSG_RESULT($cf_cv_curses_dir)
3129 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
3131 CF_PATH_SYNTAX(withval)
3132 if test -d "$cf_cv_curses_dir"
3134 CF_ADD_INCDIR($cf_cv_curses_dir/include)
3135 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
3139 dnl ---------------------------------------------------------------------------
3140 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3141 dnl ----------------
3142 dnl Configure-option for dbmalloc. The optional parameter is used to override
3143 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3144 AC_DEFUN([CF_WITH_DBMALLOC],[
3145 CF_NO_LEAKS_OPTION(dbmalloc,
3146 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
3149 if test "$with_dbmalloc" = yes ; then
3150 AC_CHECK_HEADER(dbmalloc.h,
3151 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3154 dnl ---------------------------------------------------------------------------
3155 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3157 dnl Configure-option for dmalloc. The optional parameter is used to override
3158 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3159 AC_DEFUN([CF_WITH_DMALLOC],[
3160 CF_NO_LEAKS_OPTION(dmalloc,
3161 [ --with-dmalloc test: use Gray Watson's dmalloc library],
3164 if test "$with_dmalloc" = yes ; then
3165 AC_CHECK_HEADER(dmalloc.h,
3166 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3169 dnl ---------------------------------------------------------------------------
3170 dnl CF_WITH_NCURSES_ETC version: 4 updated: 2015/04/25 20:53:11
3171 dnl -------------------
3172 dnl Use this macro for programs which use any variant of "curses", e.g.,
3173 dnl "ncurses", and "PDCurses". Programs that can use curses and some unrelated
3174 dnl library (such as slang) should use a "--with-screen=XXX" option.
3176 dnl This does not use AC_DEFUN, because that would tell autoconf to run each
3177 dnl of the macros inside this one - before this macro.
3178 define([CF_WITH_NCURSES_ETC],[
3183 AC_MSG_CHECKING(for specified curses library type)
3185 [ --with-screen=XXX use specified curses-libraries],
3186 [cf_cv_screen=$withval],[
3188 AC_ARG_WITH(ncursesw,
3189 [ --with-ncursesw use wide ncurses-libraries],
3190 [cf_cv_screen=ncursesw],[
3192 AC_ARG_WITH(ncurses,
3193 [ --with-ncurses use ncurses-libraries],
3194 [cf_cv_screen=ncurses],[
3196 AC_ARG_WITH(pdcurses,
3197 [ --with-pdcurses compile/link with pdcurses X11 library],
3198 [cf_cv_screen=pdcurses],[
3200 AC_ARG_WITH(curses-colr,
3201 [ --with-curses-colr compile/link with HPUX 10.x color-curses],
3202 [cf_cv_screen=curses_colr],[
3204 AC_ARG_WITH(curses-5lib,
3205 [ --with-curses-5lib compile/link with SunOS 5lib curses],
3206 [cf_cv_screen=curses_5lib])])])])])])
3208 AC_MSG_RESULT($cf_cv_screen)
3210 case $cf_cv_screen in
3216 CF_NCURSES_CONFIG($cf_cv_screen)
3219 CF_NCURSES_CONFIG($cf_cv_screen)
3225 AC_MSG_ERROR(unexpected screen-value: $cf_cv_screen)
3230 dnl ---------------------------------------------------------------------------
3231 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3232 dnl ----------------
3233 AC_DEFUN([CF_WITH_VALGRIND],[
3234 CF_NO_LEAKS_OPTION(valgrind,
3235 [ --with-valgrind test: use valgrind],
3238 dnl ---------------------------------------------------------------------------
3239 dnl CF_XOPEN_CURSES version: 11 updated: 2011/01/18 18:15:30
3241 dnl Test if we should define X/Open source for curses, needed on Digital Unix
3242 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
3244 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
3245 dnl as getbegy(). The latter is better design, but the former is standard.
3246 AC_DEFUN([CF_XOPEN_CURSES],
3248 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3249 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
3252 #include <${cf_cv_ncurses_header:-curses.h}>],[
3253 #if defined(NCURSES_VERSION_PATCH)
3254 #if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
3258 long x = winnstr(stdscr, "", 0);
3260 getbegyx(stdscr, y1, x1)],
3261 [cf_cv_need_xopen_extension=no],
3263 #define _XOPEN_SOURCE_EXTENDED
3265 #include <${cf_cv_ncurses_header:-curses.h}>],[
3266 #ifdef NCURSES_VERSION
3268 int check2 = curs_set((int)sizeof(check));
3270 long x = winnstr(stdscr, "", 0);
3272 getbegyx(stdscr, y1, x1)],
3273 [cf_cv_need_xopen_extension=yes],
3274 [cf_cv_need_xopen_extension=unknown])])])
3275 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
3277 dnl ---------------------------------------------------------------------------
3278 dnl CF_XOPEN_SOURCE version: 49 updated: 2015/04/12 15:39:00
3280 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3281 dnl or adapt to the vendor's definitions to get equivalent functionality,
3282 dnl without losing the common non-POSIX features.
3285 dnl $1 is the nominal value for _XOPEN_SOURCE
3286 dnl $2 is the nominal value for _POSIX_C_SOURCE
3287 AC_DEFUN([CF_XOPEN_SOURCE],[
3288 AC_REQUIRE([AC_CANONICAL_HOST])
3290 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3291 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3296 cf_xopen_source="-D_ALL_SOURCE"
3302 cf_xopen_source="-D_APPLE_C_SOURCE"
3305 cf_xopen_source="-D_DARWIN_C_SOURCE"
3308 (freebsd*|dragonfly*)
3309 # 5.x headers associate
3310 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3311 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3312 cf_POSIX_C_SOURCE=200112L
3314 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3317 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3320 cf_xopen_source="-D_HPUX_SOURCE"
3323 cf_xopen_source="-D_SGI_SOURCE"
3326 (linux*|gnu*|mint*|k*bsd*-gnu)
3330 cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
3333 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
3335 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3338 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3341 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
3342 cf_xopen_source="-D_BSD_SOURCE"
3346 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3349 cf_xopen_source="-D_OSF_SOURCE"
3352 cf_xopen_source="-D_QNX_SOURCE"
3355 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3358 cf_xopen_source="-D__EXTENSIONS__"
3359 cf_cv_xopen_source=broken
3361 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
3367 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3371 if test -n "$cf_xopen_source" ; then
3372 CF_ADD_CFLAGS($cf_xopen_source,true)
3375 dnl In anything but the default case, we may have system-specific setting
3376 dnl which is still not guaranteed to provide all of the entrypoints that
3377 dnl _XOPEN_SOURCE would yield.
3378 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
3379 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
3380 AC_TRY_COMPILE([#include <stdlib.h>],[
3381 #ifndef _XOPEN_SOURCE
3384 [cf_XOPEN_SOURCE_set=yes],
3385 [cf_XOPEN_SOURCE_set=no])
3386 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
3387 if test $cf_XOPEN_SOURCE_set = yes
3389 AC_TRY_COMPILE([#include <stdlib.h>],[
3390 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
3393 [cf_XOPEN_SOURCE_set_ok=yes],
3394 [cf_XOPEN_SOURCE_set_ok=no])
3395 if test $cf_XOPEN_SOURCE_set_ok = no
3397 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
3404 dnl ---------------------------------------------------------------------------
3405 dnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
3407 dnl Check for Xaw (Athena) libraries
3409 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
3410 AC_DEFUN([CF_X_ATHENA],
3412 cf_x_athena=${cf_x_athena:-Xaw}
3414 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
3417 [ --with-Xaw3d link with Xaw 3d library])
3418 if test "$withval" = yes ; then
3425 AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
3427 AC_ARG_WITH(Xaw3dxft,
3428 [ --with-Xaw3dxft link with Xaw 3d xft library])
3429 if test "$withval" = yes ; then
3430 cf_x_athena=Xaw3dxft
3436 AC_MSG_CHECKING(if you want to link with neXT Athena library)
3439 [ --with-neXtaw link with neXT Athena library])
3440 if test "$withval" = yes ; then
3447 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
3449 AC_ARG_WITH(XawPlus,
3450 [ --with-XawPlus link with Athena-Plus library])
3451 if test "$withval" = yes ; then
3460 if test "$PKG_CONFIG" != none ; then
3462 test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
3463 for cf_athena_pkg in \
3466 ${cf_x_athena}-devel \
3468 lib${cf_x_athena}-devel
3470 CF_TRY_PKG_CONFIG($cf_athena_pkg,[
3471 cf_x_athena_lib="$cf_pkgconfig_libs"
3472 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3473 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3477 AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
3479 #include <X11/Xmu/CharSet.h>
3481 int check = XmuCompareISOLatin1("big", "small")
3482 ],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
3484 if test "$cf_cv_xaw_compat" = no
3486 # workaround for broken ".pc" files...
3487 case "$cf_x_athena_lib" in
3491 CF_VERBOSE(work around broken package)
3493 cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
3494 CF_TRY_PKG_CONFIG(xmu,[
3496 CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
3498 CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
3509 if test -z "$cf_x_athena_lib" ; then
3512 CF_X_ATHENA_CPPFLAGS($cf_x_athena)
3513 CF_X_ATHENA_LIBS($cf_x_athena)
3516 dnl ---------------------------------------------------------------------------
3517 dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
3518 dnl --------------------
3519 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3520 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3521 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
3523 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3526 for cf_path in default \
3527 /usr/contrib/X11R6 \
3528 /usr/contrib/X11R5 \
3532 if test -z "$cf_x_athena_inc" ; then
3534 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
3535 if test $cf_path != default ; then
3536 CPPFLAGS="$cf_save -I$cf_path/include"
3537 AC_MSG_CHECKING(for $cf_test in $cf_path)
3539 AC_MSG_CHECKING(for $cf_test)
3542 #include <X11/Intrinsic.h>
3543 #include <$cf_test>],[],
3546 AC_MSG_RESULT($cf_result)
3547 if test "$cf_result" = yes ; then
3548 cf_x_athena_inc=$cf_path
3556 if test -z "$cf_x_athena_inc" ; then
3558 [Unable to successfully find Athena header files with test program])
3559 elif test "$cf_x_athena_inc" != default ; then
3560 CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
3563 dnl ---------------------------------------------------------------------------
3564 dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
3565 dnl ----------------
3566 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3567 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3568 AC_DEFUN([CF_X_ATHENA_LIBS],
3569 [AC_REQUIRE([CF_X_TOOLKIT])
3570 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3573 for cf_path in default \
3574 /usr/contrib/X11R6 \
3575 /usr/contrib/X11R5 \
3580 ${cf_x_athena_root} \
3581 ${cf_x_athena_root}7 \
3582 ${cf_x_athena_root}6
3586 "-l$cf_lib -lXpm -lXmu" \
3587 "-l${cf_lib}_s -lXmu_s"
3589 if test -z "$cf_x_athena_lib" ; then
3591 cf_test=XawSimpleMenuAddGlobalActions
3592 if test $cf_path != default ; then
3593 CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
3594 AC_MSG_CHECKING(for $cf_libs in $cf_path)
3596 CF_ADD_LIBS($cf_libs)
3597 AC_MSG_CHECKING(for $cf_test in $cf_libs)
3600 #include <X11/Intrinsic.h>
3601 #include <X11/$cf_x_athena_root/SimpleMenu.h>
3603 $cf_test((XtAppContext) 0)],
3606 AC_MSG_RESULT($cf_result)
3607 if test "$cf_result" = yes ; then
3608 cf_x_athena_lib="$cf_libs"
3614 test -n "$cf_x_athena_lib" && break
3618 if test -z "$cf_x_athena_lib" ; then
3620 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
3623 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3624 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3626 dnl ---------------------------------------------------------------------------
3627 dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
3629 AC_DEFUN([CF_X_EXT],[
3630 CF_TRY_PKG_CONFIG(Xext,,[
3631 AC_CHECK_LIB(Xext,XextCreateExtension,
3632 [CF_ADD_LIB(Xext)])])
3634 dnl ---------------------------------------------------------------------------
3635 dnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
3637 dnl Check for X Toolkit libraries
3638 AC_DEFUN([CF_X_TOOLKIT],
3640 AC_REQUIRE([AC_PATH_XTRA])
3641 AC_REQUIRE([CF_CHECK_CACHE])
3643 # OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
3644 # in some cases has installed dummy files in the former, other cases replaced
3645 # it with a link to the new location). This complicates the configure script.
3646 # Check for that pitfall, and recover using pkg-config
3648 # If none of these are set, the configuration is almost certainly broken.
3649 if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
3651 CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
3652 CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
3653 CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
3654 CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
3659 CF_TRY_PKG_CONFIG(xt,[
3665 # we have an "xt" package, but it may omit Xt's dependency on X11
3666 AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
3668 #include <X11/Xlib.h>
3670 int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
3671 int rc2 = XClearWindow((Display*) 0, (Window) 0);
3672 int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
3673 int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
3674 ],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
3675 if test "$cf_cv_xt_x11_compat" = no
3677 CF_VERBOSE(work around broken X11 dependency)
3678 # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
3679 CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
3684 AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
3686 #include <X11/Shell.h>
3687 ],[int num = IceConnectionNumber(0)
3688 ],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
3690 if test "$cf_cv_xt_ice_compat" = no
3692 # workaround for broken ".pc" files used for X Toolkit.
3693 case "x$X_PRE_LIBS" in
3699 CF_VERBOSE(work around broken ICE dependency)
3700 CF_TRY_PKG_CONFIG(ice,
3701 [CF_TRY_PKG_CONFIG(sm)],
3702 [CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
3712 LDFLAGS="$X_LIBS $LDFLAGS"
3713 CF_CHECK_CFLAGS($X_CFLAGS)
3715 AC_CHECK_FUNC(XOpenDisplay,,[
3716 AC_CHECK_LIB(X11,XOpenDisplay,
3718 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3720 AC_CHECK_FUNC(XtAppInitialize,,[
3721 AC_CHECK_LIB(Xt, XtAppInitialize,
3722 [AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
3724 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
3725 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3728 if test $cf_have_X_LIBS = no ; then
3730 [Unable to successfully link X Toolkit library (-lXt) with
3731 test program. You will have to check and add the proper libraries by hand
3735 dnl ---------------------------------------------------------------------------
3736 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
3738 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
3739 dnl are both available.
3740 define([CF__CURSES_HEAD],[
3742 #include <xcurses.h>
3743 char * XCursesProgramName = "test";
3745 #include <${cf_cv_ncurses_header:-curses.h}>
3746 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
3747 #include <ncursesw/term.h>
3748 #elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
3749 #include <ncurses/term.h>
3750 #elif defined(HAVE_TERM_H)