]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/aclocal.m4
ncurses 5.9 - patch 20150502
[ncurses.git] / test / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2003-2014,2015 Free Software Foundation, Inc.              *
3 dnl                                                                          *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
5 dnl copy of this software and associated documentation files (the            *
6 dnl "Software"), to deal in the Software without restriction, including      *
7 dnl without limitation the rights to use, copy, modify, merge, publish,      *
8 dnl distribute, distribute with modifications, sublicense, and/or sell       *
9 dnl copies of the Software, and to permit persons to whom the Software is    *
10 dnl furnished to do so, subject to the following conditions:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 dnl                                                                          *
23 dnl Except as contained in this notice, the name(s) of the above copyright   *
24 dnl holders shall not be used in advertising or otherwise to promote the     *
25 dnl sale, use or other dealings in this Software without prior written       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl $Id: aclocal.m4,v 1.113 2015/05/01 00:39:44 tom Exp $
30 dnl
31 dnl Author: Thomas E. Dickey
32 dnl
33 dnl Macros used in NCURSES test programs auto-configuration script.
34 dnl
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.
38 dnl
39 dnl See http://invisible-island.net/autoconf/ for additional information.
40 dnl
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.
46 dnl
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],
51 [
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
70 dnl -------------
71 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
72 dnl The second parameter if given makes this macro verbose.
73 dnl
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],
78 [
79 cf_fix_cppflags=no
80 cf_new_cflags=
81 cf_new_cppflags=
82 cf_new_extra_cppflags=
83
84 for cf_add_cflags in $1
85 do
86 case $cf_fix_cppflags in
87 (no)
88         case $cf_add_cflags in
89         (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
90                 case $cf_add_cflags in
91                 (-D*)
92                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
93
94                         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
95                                 && test -z "${cf_tst_cflags}" \
96                                 && cf_fix_cppflags=yes
97
98                         if test $cf_fix_cppflags = yes ; then
99                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
100                                 continue
101                         elif test "${cf_tst_cflags}" = "\"'" ; then
102                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
103                                 continue
104                         fi
105                         ;;
106                 esac
107                 case "$CPPFLAGS" in
108                 (*$cf_add_cflags)
109                         ;;
110                 (*)
111                         case $cf_add_cflags in
112                         (-D*)
113                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
114                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
115                                 ;;
116                         esac
117                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
118                         ;;
119                 esac
120                 ;;
121         (*)
122                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
123                 ;;
124         esac
125         ;;
126 (yes)
127         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
128
129         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
130
131         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
132                 && test -z "${cf_tst_cflags}" \
133                 && cf_fix_cppflags=no
134         ;;
135 esac
136 done
137
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"
141 fi
142
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"
146 fi
147
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"
151 fi
152
153 AC_SUBST(EXTRA_CPPFLAGS)
154
155 ])dnl
156 dnl ---------------------------------------------------------------------------
157 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
158 dnl -------------
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],
165 [
166 if test -n "$1" ; then
167   for cf_add_incdir in $1
168   do
169         while test $cf_add_incdir != /usr/include
170         do
171           if test -d $cf_add_incdir
172           then
173                 cf_have_incdir=no
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
179                         fi
180                   done
181                 fi
182
183                 if test "$cf_have_incdir" = no ; then
184                   if test "$cf_add_incdir" = /usr/local/include ; then
185                         if test "$GCC" = yes
186                         then
187                           cf_save_CPPFLAGS=$CPPFLAGS
188                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
189                           AC_TRY_COMPILE([#include <stdio.h>],
190                                   [printf("Hello")],
191                                   [],
192                                   [cf_have_incdir=yes])
193                           CPPFLAGS=$cf_save_CPPFLAGS
194                         fi
195                   fi
196                 fi
197
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"
201
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"
205                 else
206                   break
207                 fi
208           fi
209         done
210   done
211 fi
212 ])dnl
213 dnl ---------------------------------------------------------------------------
214 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
215 dnl ----------
216 dnl Add a library, used to enforce consistency.
217 dnl
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
223 dnl -------------
224 dnl     Adds to the library-path
225 dnl
226 dnl     Some machines have trouble with multiple -L options.
227 dnl
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)
230 dnl
231 AC_DEFUN([CF_ADD_LIBDIR],
232 [
233 if test -n "$1" ; then
234         for cf_add_libdir in $1
235         do
236                 if test $cf_add_libdir = /usr/lib ; then
237                         :
238                 elif test -d $cf_add_libdir
239                 then
240                         cf_have_libdir=no
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
246                                         fi
247                                 done
248                         fi
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])"
252                         fi
253                 fi
254         done
255 fi
256 ])dnl
257 dnl ---------------------------------------------------------------------------
258 dnl CF_ADD_LIBS version: 2 updated: 2014/07/13 14:33:27
259 dnl -----------
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.
263 dnl
264 dnl $1 = libraries to add, with the "-l", etc.
265 dnl $2 = variable to update (default $LIBS)
266 AC_DEFUN([CF_ADD_LIBS],[
267 cf_add_libs="$1"
268 # Filter out duplicates - this happens with badly-designed ".pc" files...
269 for cf_add_1lib in [$]ifelse($2,,LIBS,[$2])
270 do
271         for cf_add_2lib in $cf_add_libs
272         do
273                 if test "x$cf_add_1lib" = "x$cf_add_2lib"
274                 then
275                         cf_add_1lib=
276                         break
277                 fi
278         done
279         test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
280 done
281 ifelse($2,,LIBS,[$2])="$cf_add_libs"
282 ])dnl
283 dnl ---------------------------------------------------------------------------
284 dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
285 dnl ----------------
286 dnl Add a given library after another, e.g., following the one it satisfies a
287 dnl dependency for.
288 dnl
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)
295 ])dnl
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],
306 [
307 test "x$4" != "x$5" && \
308 test -d "$4" && \
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"
316 }
317 ])dnl
318 dnl ---------------------------------------------------------------------------
319 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
320 dnl --------------
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
326 dnl -------------
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
332 dnl -------------
333 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
334 dnl values.
335 dnl
336 dnl Parameters:
337 dnl $1 = option name
338 dnl $2 = help-string
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
345 ifelse([$3],,[    :]dnl
346 ,[    $3]) ifelse([$4],,,[
347   else
348     $4])
349   fi],[enableval=$5 ifelse([$4],,,[
350   $4
351 ])dnl
352   ])])dnl
353 dnl ---------------------------------------------------------------------------
354 dnl CF_CC_ENV_FLAGS version: 2 updated: 2015/04/12 15:39:00
355 dnl ---------------
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],
360 [
361 # This should have been defined by AC_PROG_CC
362 : ${CC:=cc}
363
364 AC_MSG_CHECKING(\$CC variable)
365 case "$CC" in
366 (*[[\ \ ]]-[[IUD]]*)
367         AC_MSG_RESULT(broken)
368         AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
369         # humor him...
370         cf_flags=`echo "$CC" | sed -e 's/^[[^   ]]*[[   ]]//'`
371         CC=`echo "$CC" | sed -e 's/[[   ]].*//'`
372         CF_ADD_CFLAGS($cf_flags)
373         ;;
374 (*)
375         AC_MSG_RESULT(ok)
376         ;;
377 esac
378 ])dnl
379 dnl ---------------------------------------------------------------------------
380 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
381 dnl --------------
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.
384 dnl
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.
389 dnl
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],
393 [
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"
397 else
398         system_name="`(uname -s -r) 2>/dev/null`"
399         if test -z "$system_name" ; then
400                 system_name="`(hostname) 2>/dev/null`"
401         fi
402 fi
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"])
405
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)
408
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.")
412 fi
413 ])dnl
414 dnl ---------------------------------------------------------------------------
415 dnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
416 dnl ---------------
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],
422 [
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)
432          fi
433          CFLAGS="$cf_check_flags"])
434 fi
435 ])dnl
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],
443 [
444 AC_CHECK_LIB($1$2,$3,[
445 CF_UPPER(cf_upper,have_lib$1)
446 CF_ADD_LIBS(-l$1$2)
447 AC_DEFINE_UNQUOTED($cf_upper,1)])
448 ])dnl
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.
455 dnl
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.
459 dnl
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
465
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"
470         AC_TRY_COMPILE([],[
471 #ifdef __clang__
472 #else
473 make an error
474 #endif
475 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
476 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
477 ],[])
478         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
479         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
480 fi
481 ])
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],
487 [
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
492 do
493 AC_TRY_LINK([
494 #include <${cf_cv_ncurses_header:-curses.h}>
495 ],[
496 $name['k'] = ACS_PLUS
497 ],[cf_cv_curses_acs_map=$name; break])
498 done
499 ])
500
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_])
502 ])
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],
509 [
510 AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header:-curses.h})
511
512 AC_TRY_COMPILE(CF__CURSES_HEAD,[
513 void *foo = &($1)
514 ],cf_result=yes,cf_result=no)
515 AC_MSG_RESULT($cf_result)
516
517 if test $cf_result = yes ; then
518         CF_UPPER(cf_result,have_curses_data_$1)
519         AC_DEFINE_UNQUOTED($cf_result)
520 else
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
524 [
525 extern char $1;
526 int main(void)
527 {
528         void *foo = &($1);
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],[
532         # cross-compiling
533         AC_TRY_LINK(CF__CURSES_HEAD
534 [extern char $1;],[
535         do {
536                 void *foo = &($1);
537                 fprintf(stderr, "testing linkage of $1:%p\n", foo);
538                 ${cf_cv_main_return:-return}(foo == 0);
539         } while (0)
540 ],[cf_result=yes],[cf_result=no])
541 ])
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)
546         fi
547 fi
548 ])dnl
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],
554 [
555 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header:-curses.h})
556 AC_TRY_COMPILE([
557 #ifndef _XOPEN_SOURCE_EXTENDED
558 #define _XOPEN_SOURCE_EXTENDED
559 #endif
560 #include <${cf_cv_ncurses_header:-curses.h}>],[
561 $1 foo
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])
567 else
568         AC_DEFINE_UNQUOTED($1,$2,[Define to appropriate type if $1 is not declared])
569 fi
570 ])dnl
571 dnl ---------------------------------------------------------------------------
572 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
573 dnl ----------------
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],
578 [
579 CF_CURSES_CPPFLAGS
580 CF_NCURSES_VERSION
581 CF_CURSES_LIBS
582 ])dnl
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],[
588
589 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
590 cf_cv_curses_incdir=no
591 case $host_os in
592 (hpux10.*)
593         if test "x$cf_cv_screen" = "xcurses_colr"
594         then
595                 test -d /usr/include/curses_colr && \
596                 cf_cv_curses_incdir="-I/usr/include/curses_colr"
597         fi
598         ;;
599 (sunos3*|sunos4*)
600         if test "x$cf_cv_screen" = "xcurses_5lib"
601         then
602                 test -d /usr/5lib && \
603                 test -d /usr/5include && \
604                 cf_cv_curses_incdir="-I/usr/5include"
605         fi
606         ;;
607 esac
608 ])
609 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
610
611 CF_CURSES_HEADER
612 CF_TERM_HEADER
613 ])dnl
614 dnl ---------------------------------------------------------------------------
615 dnl CF_CURSES_FUNCS version: 18 updated: 2014/07/19 18:44:41
616 dnl ---------------
617 dnl Curses-functions are a little complicated, since a lot of them are macros.
618 AC_DEFUN([CF_CURSES_FUNCS],
619 [
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])
624 for cf_func in $1
625 do
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,
633                         [
634 #ifndef ${cf_func}
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);
639 #endif
640                         ],
641                         [cf_result=yes],
642                         [cf_result=no])
643                 fi
644                 eval 'cf_cv_func_'$cf_func'=$cf_result'
645         ])
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})
651         fi
652 done
653 ])dnl
654 dnl ---------------------------------------------------------------------------
655 dnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
656 dnl ----------------
657 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
658 dnl variations of ncurses' installs.
659 dnl
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
664 for cf_header in \
665         ncurses.h ifelse($1,,,[$1/ncurses.h]) \
666         curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
667 do
668 AC_TRY_COMPILE([#include <${cf_header}>],
669         [initscr(); tgoto("?", 0,0)],
670         [cf_cv_ncurses_header=$cf_header; break],[])
671 done
672 ])
673
674 if test "$cf_cv_ncurses_header" = none ; then
675         AC_MSG_ERROR(No curses header-files found)
676 fi
677
678 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
679 AC_CHECK_HEADERS($cf_cv_ncurses_header)
680 ])dnl
681 dnl ---------------------------------------------------------------------------
682 dnl CF_CURSES_LIBS version: 38 updated: 2015/04/15 19:08:48
683 dnl --------------
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],[
687
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)],
692     cf_result=yes,
693     cf_result=no)
694 AC_MSG_RESULT($cf_result)
695
696 if test "$cf_result" = no ; then
697 case $host_os in
698 (freebsd*)
699     AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
700     ;;
701 (hpux10.*)
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"
707         then
708                 AC_CHECK_LIB(cur_colr,initscr,[
709                         CF_ADD_LIBS(-lcur_colr)
710                         ac_cv_func_initscr=yes
711                         ],[
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
717                         ])])
718         fi
719         ;;
720 (linux*)
721         case `arch 2>/dev/null` in
722         (x86_64)
723                 if test -d /lib64
724                 then
725                         CF_ADD_LIBDIR(/lib64)
726                 else
727                         CF_ADD_LIBDIR(/lib)
728                 fi
729                 ;;
730         (*)
731                 CF_ADD_LIBDIR(/lib)
732                 ;;
733         esac
734         ;;
735 (sunos3*|sunos4*)
736         if test "x$cf_cv_screen" = "xcurses_5lib"
737         then
738                 if test -d /usr/5lib ; then
739                         CF_ADD_LIBDIR(/usr/5lib)
740                         CF_ADD_LIBS(-lcurses -ltermcap)
741                 fi
742     fi
743     ac_cv_func_initscr=yes
744     ;;
745 esac
746
747 if test ".$ac_cv_func_initscr" != .yes ; then
748         cf_save_LIBS="$LIBS"
749
750         if test ".${cf_cv_ncurses_version:-no}" != .no
751         then
752                 cf_check_list="ncurses curses cursesX"
753         else
754                 cf_check_list="cursesX curses ncurses"
755         fi
756
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
760         then
761                 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
762                         for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
763                         do
764                                 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
765                         done
766                 ])
767         fi
768
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
772         then
773                 for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
774                 do
775                         AC_CHECK_LIB($cf_curs_lib,initscr,[break])
776                 done
777         fi
778         test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
779
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}>],
784                         [initscr()],
785                         [cf_result=yes],
786                         [cf_result=no])
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
790                 :
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);],
795                         [cf_result=no],
796                         [
797                         LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
798                         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
799                                 [initscr()],
800                                 [cf_result=yes],
801                                 [cf_result=error])
802                         ])
803                 AC_MSG_RESULT($cf_result)
804         fi
805 fi
806 fi
807
808 ])dnl
809 dnl ---------------------------------------------------------------------------
810 dnl CF_CURSES_TERM_H version: 11 updated: 2015/04/15 19:08:48
811 dnl ----------------
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],
817 [
818 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
819
820 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
821
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.
824
825 cf_header_list="term.h ncurses/term.h ncursesw/term.h"
826
827 case ${cf_cv_ncurses_header:-curses.h} in
828 (*/*)
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"
831         ;;
832 esac
833
834 for cf_header in $cf_header_list
835 do
836         AC_TRY_COMPILE([
837 #include <${cf_cv_ncurses_header:-curses.h}>
838 #include <${cf_header}>],
839         [WINDOW *x],
840         [cf_cv_term_header=$cf_header
841          break],
842         [cf_cv_term_header=no])
843 done
844
845 case $cf_cv_term_header in
846 (no)
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
850         do
851                 AC_TRY_COMPILE([
852 #include <${cf_cv_ncurses_header:-curses.h}>
853 #ifdef NCURSES_VERSION
854 #include <${cf_header}>
855 #else
856 make an error
857 #endif],
858                         [WINDOW *x],
859                         [cf_cv_term_header=$cf_header
860                          break],
861                         [cf_cv_term_header=no])
862         done
863         ;;
864 esac
865 ])
866
867 case $cf_cv_term_header in
868 (term.h)
869         AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
870         ;;
871 (ncurses/term.h)
872         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
873         ;;
874 (ncursesw/term.h)
875         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
876         ;;
877 esac
878 ])dnl
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
885 dnl broken).
886 AC_DEFUN([CF_CURSES_UNCTRL_H],
887 [
888 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
889
890 AC_CACHE_CHECK(for unctrl.h, cf_cv_unctrl_header,[
891
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.
894
895 cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
896
897 case ${cf_cv_ncurses_header:-curses.h} in
898 (*/*)
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"
901         ;;
902 esac
903
904 for cf_header in $cf_header_list
905 do
906         AC_TRY_COMPILE([
907 #include <${cf_cv_ncurses_header:-curses.h}>
908 #include <${cf_header}>],
909         [WINDOW *x],
910         [cf_cv_unctrl_header=$cf_header
911          break],
912         [cf_cv_unctrl_header=no])
913 done
914 ])
915
916 case $cf_cv_unctrl_header in
917 (no)
918         AC_MSG_WARN(unctrl.h header not found)
919         ;;
920 esac
921
922 case $cf_cv_unctrl_header in
923 (unctrl.h)
924         AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
925         ;;
926 (ncurses/unctrl.h)
927         AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
928         ;;
929 (ncursesw/unctrl.h)
930         AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
931         ;;
932 esac
933 ])dnl
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],
939 [
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
943         do
944         AC_TRY_LINK([
945 #ifndef _XOPEN_SOURCE_EXTENDED
946 #define _XOPEN_SOURCE_EXTENDED
947 #endif
948 #include <${cf_cv_ncurses_header:-curses.h}>],
949         [void *foo = &($name['k'])],
950         [cf_cv_curses_wacs_map=$name
951          break])
952         done])
953
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])
955 ])dnl
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],
963 [
964 AC_REQUIRE([CF_CURSES_WACS_MAP])
965
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
969 then
970         AC_TRY_LINK([
971 #ifndef _XOPEN_SOURCE_EXTENDED
972 #define _XOPEN_SOURCE_EXTENDED
973 #endif
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])
978 else
979         AC_TRY_LINK([
980 #ifndef _XOPEN_SOURCE_EXTENDED
981 #define _XOPEN_SOURCE_EXTENDED
982 #endif
983 #include <${cf_cv_ncurses_header:-curses.h}>],
984         [cchar_t *foo = WACS_PLUS],
985         [cf_cv_curses_wacs_symbols=yes])
986 fi
987 ])
988
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])
990 ])dnl
991 dnl ---------------------------------------------------------------------------
992 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
993 dnl ----------
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
998 dnl ---------------
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.
1001 dnl
1002 dnl Sets:
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
1008 dnl
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],
1013         [
1014         ECHO_LT='--silent'
1015         ECHO_LD='@echo linking [$]@;'
1016         RULE_CC='@echo compiling [$]<'
1017         SHOW_CC='@echo compiling [$]@'
1018         ECHO_CC='@'
1019 ],[
1020         ECHO_LT=''
1021         ECHO_LD=''
1022         RULE_CC=''
1023         SHOW_CC=''
1024         ECHO_CC=''
1025 ])
1026 AC_MSG_RESULT($enableval)
1027 AC_SUBST(ECHO_LT)
1028 AC_SUBST(ECHO_LD)
1029 AC_SUBST(RULE_CC)
1030 AC_SUBST(SHOW_CC)
1031 AC_SUBST(ECHO_CC)
1032 ])dnl
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
1037 dnl checks.
1038 AC_DEFUN([CF_DISABLE_LEAKS],[
1039
1040 AC_REQUIRE([CF_WITH_DMALLOC])
1041 AC_REQUIRE([CF_WITH_DBMALLOC])
1042 AC_REQUIRE([CF_WITH_VALGRIND])
1043
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)
1050
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.])
1054 fi
1055 ])dnl
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],
1064 [
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
1072         CF_RPATH_HACK
1073 fi
1074 ])
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 )
1081 then
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],
1086         [with_warnings=no])
1087 AC_MSG_RESULT($with_warnings)
1088 if test "$with_warnings" = "yes"
1089 then
1090         CF_GCC_ATTRIBUTES
1091         CF_GCC_WARNINGS
1092 fi
1093 fi
1094 ])dnl
1095 dnl ---------------------------------------------------------------------------
1096 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
1097 dnl ---------------
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
1103 dnl     $3 = includes
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
1107 dnl
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],
1111 [
1112         eval 'cf_cv_have_lib_'$1'=no'
1113         cf_libdir=""
1114         AC_CHECK_FUNC($5,
1115                 eval 'cf_cv_have_lib_'$1'=yes',[
1116                 cf_save_LIBS="$LIBS"
1117                 AC_MSG_CHECKING(for $5 in -l$1)
1118                 LIBS="-l$1 $LIBS"
1119                 AC_TRY_LINK([$3],[$4],
1120                         [AC_MSG_RESULT(yes)
1121                          eval 'cf_cv_have_lib_'$1'=yes'
1122                         ],
1123                         [AC_MSG_RESULT(no)
1124                         CF_LIBRARY_PATH(cf_search,$2)
1125                         for cf_libdir in $cf_search
1126                         do
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],
1130                                         [AC_MSG_RESULT(yes)
1131                                          eval 'cf_cv_have_lib_'$1'=yes'
1132                                          break],
1133                                         [AC_MSG_RESULT(no)
1134                                          LIBS="$cf_save_LIBS"])
1135                         done
1136                         ])
1137                 ])
1138 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
1139 ifelse($6,,[
1140 if test $cf_found_library = no ; then
1141         AC_MSG_ERROR(Cannot link $1 library)
1142 fi
1143 ])
1144 ])dnl
1145 dnl ---------------------------------------------------------------------------
1146 dnl CF_FIND_LINKAGE version: 20 updated: 2015/04/18 08:56:57
1147 dnl ---------------
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.
1151 dnl
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
1160 dnl
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],[
1167
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=
1172
1173 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1174
1175 cf_save_LIBS="$LIBS"
1176
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
1181 ],[
1182
1183 LIBS="-l$3 $7 $cf_save_LIBS"
1184
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"
1190 ],[
1191         cf_cv_find_linkage_$3=no
1192         LIBS="$cf_save_LIBS"
1193
1194         CF_VERBOSE(find linkage for $3 library)
1195         CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1196
1197         cf_save_CPPFLAGS="$CPPFLAGS"
1198         cf_test_CPPFLAGS="$CPPFLAGS"
1199
1200         CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1201         for cf_cv_header_path_$3 in $cf_search
1202         do
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"
1210                                 break],[
1211                                 CPPFLAGS="$cf_save_CPPFLAGS"
1212                                 ])
1213                 fi
1214         done
1215
1216         if test "$cf_cv_find_linkage_$3" = maybe ; then
1217
1218                 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1219
1220                 cf_save_LIBS="$LIBS"
1221                 cf_save_LDFLAGS="$LDFLAGS"
1222
1223                 ifelse([$6],,,[
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"
1231                         ])
1232
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
1236                         do
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"
1246                                         break],[
1247                                         CPPFLAGS="$cf_save_CPPFLAGS"
1248                                         LIBS="$cf_save_LIBS"
1249                                         LDFLAGS="$cf_save_LDFLAGS"
1250                                         ])
1251                                 fi
1252                         done
1253                         CPPFLAGS="$cf_save_CPPFLAGS"
1254                         LDFLAGS="$cf_save_LDFLAGS"
1255                 fi
1256
1257         else
1258                 cf_cv_find_linkage_$3=no
1259         fi
1260         ],$7)
1261 ])
1262
1263 LIBS="$cf_save_LIBS"
1264
1265 if test "$cf_cv_find_linkage_$3" = yes ; then
1266 ifelse([$4],,[
1267         CF_ADD_INCDIR($cf_cv_header_path_$3)
1268         CF_ADD_LIBDIR($cf_cv_library_path_$3)
1269         CF_ADD_LIB($3)
1270 ],[$4])
1271 else
1272 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1273 fi
1274 ])dnl
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],
1281 [
1282 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
1283 AC_TRY_RUN([
1284 #include <${cf_cv_ncurses_header:-curses.h}>
1285 int main()
1286 {
1287         char temp[1024];
1288         sprintf(temp, "%s\n", curses_version());
1289         ${cf_cv_main_return:-return}(0);
1290 }]
1291 ,[cf_cv_func_curses_version=yes]
1292 ,[cf_cv_func_curses_version=no]
1293 ,[cf_cv_func_curses_version=unknown])
1294 rm -f core])
1295 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION,1,[Define to 1 if we have curses_version function])
1296 ])
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],
1304 [
1305 if test "$GCC" = yes
1306 then
1307 cat > conftest.i <<EOF
1308 #ifndef GCC_PRINTF
1309 #define GCC_PRINTF 0
1310 #endif
1311 #ifndef GCC_SCANF
1312 #define GCC_SCANF 0
1313 #endif
1314 #ifndef GCC_NORETURN
1315 #define GCC_NORETURN /* nothing */
1316 #endif
1317 #ifndef GCC_UNUSED
1318 #define GCC_UNUSED /* nothing */
1319 #endif
1320 EOF
1321 if test "$GCC" = yes
1322 then
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"
1329 #if     GCC_PRINTF
1330 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1331 #else
1332 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1333 #endif
1334 #if     GCC_SCANF
1335 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1336 #else
1337 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1338 #endif
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; }
1343 EOF
1344         cf_printf_attribute=no
1345         cf_scanf_attribute=no
1346         for cf_attribute in scanf printf unused noreturn
1347         do
1348                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1349                 cf_directive="__attribute__(($cf_attribute))"
1350                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1351
1352                 case $cf_attribute in
1353                 (printf)
1354                         cf_printf_attribute=yes
1355                         cat >conftest.h <<EOF
1356 #define GCC_$cf_ATTRIBUTE 1
1357 EOF
1358                         ;;
1359                 (scanf)
1360                         cf_scanf_attribute=yes
1361                         cat >conftest.h <<EOF
1362 #define GCC_$cf_ATTRIBUTE 1
1363 EOF
1364                         ;;
1365                 (*)
1366                         cat >conftest.h <<EOF
1367 #define GCC_$cf_ATTRIBUTE $cf_directive
1368 EOF
1369                         ;;
1370                 esac
1371
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
1376                         (noreturn)
1377                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
1378                                 ;;
1379                         (printf)
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.])
1384                                 fi
1385                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
1386                                 ;;
1387                         (scanf)
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.])
1392                                 fi
1393                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
1394                                 ;;
1395                         (unused)
1396                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
1397                                 ;;
1398                         esac
1399                 fi
1400         done
1401 else
1402         fgrep define conftest.i >>confdefs.h
1403 fi
1404 rm -rf conftest*
1405 fi
1406 ])dnl
1407 dnl ---------------------------------------------------------------------------
1408 dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
1409 dnl --------------
1410 dnl Find version of gcc
1411 AC_DEFUN([CF_GCC_VERSION],[
1412 AC_REQUIRE([AC_PROG_CC])
1413 GCC_VERSION=none
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)
1419 fi
1420 ])dnl
1421 dnl ---------------------------------------------------------------------------
1422 dnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
1423 dnl ---------------
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:
1426 dnl
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".
1432 dnl     -pedantic
1433 dnl
1434 dnl Parameter:
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
1437 dnl             -Wno-unused
1438 dnl Special:
1439 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1440 dnl
1441 AC_DEFUN([CF_GCC_WARNINGS],
1442 [
1443 AC_REQUIRE([CF_GCC_VERSION])
1444 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1445 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
1446
1447 cat > conftest.$ac_ext <<EOF
1448 #line __oline__ "${as_me:-configure}"
1449 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1450 EOF
1451
1452 if test "$INTEL_COMPILER" = yes
1453 then
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
1464
1465         AC_CHECKING([for $CC warning options])
1466         cf_save_CFLAGS="$CFLAGS"
1467         EXTRA_CFLAGS="-Wall"
1468         for cf_opt in \
1469                 wd1419 \
1470                 wd1683 \
1471                 wd1684 \
1472                 wd193 \
1473                 wd593 \
1474                 wd279 \
1475                 wd810 \
1476                 wd869 \
1477                 wd981
1478         do
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"
1483                 fi
1484         done
1485         CFLAGS="$cf_save_CFLAGS"
1486
1487 elif test "$GCC" = yes
1488 then
1489         AC_CHECKING([for $CC warning options])
1490         cf_save_CFLAGS="$CFLAGS"
1491         EXTRA_CFLAGS=
1492         cf_warn_CONST=""
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 \
1498                 Wcast-align \
1499                 Wcast-qual \
1500                 Wdeclaration-after-statement \
1501                 Wextra \
1502                 Winline \
1503                 Wmissing-declarations \
1504                 Wmissing-prototypes \
1505                 Wnested-externs \
1506                 Wpointer-arith \
1507                 Wshadow \
1508                 Wstrict-prototypes \
1509                 Wundef $cf_gcc_warnings $cf_warn_CONST $1
1510         do
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)
1514                         case $cf_opt in
1515                         (Wcast-qual)
1516                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1517                                 ;;
1518                         (Winline)
1519                                 case $GCC_VERSION in
1520                                 ([[34]].*)
1521                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1522                                         continue;;
1523                                 esac
1524                                 ;;
1525                         (Wpointer-arith)
1526                                 case $GCC_VERSION in
1527                                 ([[12]].*)
1528                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1529                                         continue;;
1530                                 esac
1531                                 ;;
1532                         esac
1533                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1534                 fi
1535         done
1536         CFLAGS="$cf_save_CFLAGS"
1537 fi
1538 rm -rf conftest*
1539
1540 AC_SUBST(EXTRA_CFLAGS)
1541 ])dnl
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],
1548 [
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
1553 do
1554 AC_TRY_COMPILE([
1555 #include <$cf_header>],
1556 [int x = optind; char *y = optarg],
1557 [cf_cv_getopt_header=$cf_header
1558  break])
1559 done
1560 ])
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])
1563 fi
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])
1566 fi
1567 ])dnl
1568 dnl ---------------------------------------------------------------------------
1569 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1570 dnl -------------
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.
1575 dnl
1576 dnl Well, yes we could work around it...
1577 AC_DEFUN([CF_GNU_SOURCE],
1578 [
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
1582 make an error
1583 #endif],
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
1589 make an error
1590 #endif],
1591         [cf_cv_gnu_source=no],
1592         [cf_cv_gnu_source=yes])
1593         CPPFLAGS="$cf_save"
1594         ])
1595 ])
1596 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1597 ])dnl
1598 dnl ---------------------------------------------------------------------------
1599 dnl CF_HEADER_PATH version: 13 updated: 2015/04/15 19:08:48
1600 dnl --------------
1601 dnl Construct a search-list of directories for a nonstandard header-file
1602 dnl
1603 dnl Parameters
1604 dnl     $1 = the variable to return as result
1605 dnl     $2 = the package name
1606 AC_DEFUN([CF_HEADER_PATH],
1607 [
1608 $1=
1609
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
1614         do
1615                 case $cf_header_path in
1616                 (-I*)
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"
1620                         ;;
1621                 esac
1622         done
1623 fi
1624
1625 # add the variations for the package we are looking for
1626 CF_SUBDIR_PATH($1,$2,include)
1627
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"
1633 }
1634
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"
1640 }
1641
1642 $1="[$]$1 $cf_header_path_list"
1643 ])dnl
1644 dnl ---------------------------------------------------------------------------
1645 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1646 dnl ---------------
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
1650 ])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],
1656 [
1657 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1658 ])dnl
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.
1665 dnl
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.
1669 dnl
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
1676
1677 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1678         case $host_os in
1679         (linux*|gnu*)
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"
1683                 AC_TRY_COMPILE([],[
1684 #ifdef __INTEL_COMPILER
1685 #else
1686 make an error
1687 #endif
1688 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1689 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1690 ],[])
1691                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1692                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1693                 ;;
1694         esac
1695 fi
1696 ])dnl
1697 dnl ---------------------------------------------------------------------------
1698 dnl CF_LD_RPATH_OPT version: 6 updated: 2015/04/12 15:39:00
1699 dnl ---------------
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],
1703 [
1704 AC_REQUIRE([CF_CHECK_CACHE])
1705
1706 LD_RPATH_OPT=
1707 AC_MSG_CHECKING(for an rpath option)
1708 case $cf_cv_system_name in
1709 (irix*)
1710         if test "$GCC" = yes; then
1711                 LD_RPATH_OPT="-Wl,-rpath,"
1712         else
1713                 LD_RPATH_OPT="-rpath "
1714         fi
1715         ;;
1716 (linux*|gnu*|k*bsd*-gnu)
1717         LD_RPATH_OPT="-Wl,-rpath,"
1718         ;;
1719 (openbsd[[2-9]].*|mirbsd*)
1720         LD_RPATH_OPT="-Wl,-rpath,"
1721         ;;
1722 (dragonfly*|freebsd*)
1723         LD_RPATH_OPT="-rpath "
1724         ;;
1725 (netbsd*)
1726         LD_RPATH_OPT="-Wl,-rpath,"
1727         ;;
1728 (osf*|mls+*)
1729         LD_RPATH_OPT="-rpath "
1730         ;;
1731 (solaris2*)
1732         LD_RPATH_OPT="-R"
1733         ;;
1734 (*)
1735         ;;
1736 esac
1737 AC_MSG_RESULT($LD_RPATH_OPT)
1738
1739 case "x$LD_RPATH_OPT" in
1740 (x-R*)
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 "
1748         ;;
1749 esac
1750 ])dnl
1751 dnl ---------------------------------------------------------------------------
1752 dnl CF_LIBRARY_PATH version: 10 updated: 2015/04/15 19:08:48
1753 dnl ---------------
1754 dnl Construct a search-list of directories for a nonstandard library-file
1755 dnl
1756 dnl Parameters
1757 dnl     $1 = the variable to return as result
1758 dnl     $2 = the package name
1759 AC_DEFUN([CF_LIBRARY_PATH],
1760 [
1761 $1=
1762 cf_library_path_list=""
1763 if test -n "${LDFLAGS}${LIBS}" ; then
1764         for cf_library_path in $LDFLAGS $LIBS
1765         do
1766                 case $cf_library_path in
1767                 (-L*)
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"
1771                         ;;
1772                 esac
1773         done
1774 fi
1775
1776 CF_SUBDIR_PATH($1,$2,lib)
1777
1778 $1="$cf_library_path_list [$]$1"
1779 ])dnl
1780 dnl ---------------------------------------------------------------------------
1781 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1782 dnl ------------
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])
1787
1788 AC_CHECK_PROGS(CTAGS, exctags ctags)
1789 AC_CHECK_PROGS(ETAGS, exetags etags)
1790
1791 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1792
1793 if test "$cf_cv_mixedcase" = yes ; then
1794         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1795 else
1796         MAKE_UPPER_TAGS=no
1797 fi
1798
1799 if test "$MAKE_UPPER_TAGS" = yes ; then
1800         MAKE_UPPER_TAGS=
1801 else
1802         MAKE_UPPER_TAGS="#"
1803 fi
1804
1805 if test "$MAKE_LOWER_TAGS" = yes ; then
1806         MAKE_LOWER_TAGS=
1807 else
1808         MAKE_LOWER_TAGS="#"
1809 fi
1810
1811 AC_SUBST(CTAGS)
1812 AC_SUBST(ETAGS)
1813
1814 AC_SUBST(MAKE_UPPER_TAGS)
1815 AC_SUBST(MAKE_LOWER_TAGS)
1816 ])dnl
1817 dnl ---------------------------------------------------------------------------
1818 dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
1819 dnl -----------
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],
1824 [
1825 AC_CACHE_CHECK(if -lm needed for math functions,
1826         cf_cv_need_libm,[
1827         AC_TRY_LINK([
1828         #include <stdio.h>
1829         #include <math.h>
1830         ],
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
1835 then
1836 ifelse($1,,[
1837         CF_ADD_LIB(m)
1838 ],[$1=-lm])
1839 fi
1840 ])
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],
1847 [
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*)
1852                 cf_cv_mixedcase=no
1853                 ;;
1854         (*)
1855                 cf_cv_mixedcase=yes
1856                 ;;
1857         esac
1858 else
1859         rm -f conftest CONFTEST
1860         echo test >conftest
1861         if test -f CONFTEST ; then
1862                 cf_cv_mixedcase=no
1863         else
1864                 cf_cv_mixedcase=yes
1865         fi
1866         rm -f conftest CONFTEST
1867 fi
1868 ])
1869 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1870 ])dnl
1871 dnl ---------------------------------------------------------------------------
1872 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1873 dnl ----------
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
1878 ])dnl
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],[
1887         AC_TRY_COMPILE([
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 */
1892 ])[
1893 #include <$2>],[
1894 #ifdef NCURSES_VERSION
1895 ]ifelse($3,ncursesw,[
1896 #ifndef WACS_BSSB
1897         make an error
1898 #endif
1899 ])[
1900 printf("%s\n", NCURSES_VERSION);
1901 #else
1902 #ifdef __NCURSES_H
1903 printf("old\n");
1904 #else
1905         make an error
1906 #endif
1907 #endif
1908         ]
1909         ,[$1=$2]
1910         ,[$1=no])
1911 ])dnl
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
1916 dnl order:
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
1920 dnl
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
1926
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
1930                 AC_MSG_RESULT(yes)
1931
1932                 AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
1933                 cf_have_ncuconfig=unknown
1934
1935                 cf_save_CPPFLAGS="$CPPFLAGS"
1936                 cf_save_LIBS="$LIBS"
1937
1938                 CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
1939                 CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
1940
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}>
1944                                 int main(void)
1945                                 { char *xx = curses_version(); return (xx == 0); }],
1946                                 [cf_have_ncuconfig=yes],
1947                                 [cf_have_ncuconfig=no])],
1948                         [cf_have_ncuconfig=no])
1949
1950                 AC_MSG_RESULT($cf_have_ncuconfig)
1951                 if test "$cf_have_ncuconfig" != "yes"
1952                 then
1953                         CPPFLAGS="$cf_save_CPPFLAGS"
1954                         LIBS="$cf_save_LIBS"
1955                         NCURSES_CONFIG_PKG=none
1956                 else
1957                         AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1958                         NCURSES_CONFIG_PKG=$cf_ncuconfig_root
1959                 fi
1960
1961         else
1962                 AC_MSG_RESULT(no)
1963                 NCURSES_CONFIG_PKG=none
1964         fi
1965 else
1966         NCURSES_CONFIG_PKG=none
1967 fi
1968
1969 if test "x$cf_have_ncuconfig" = "xno"; then
1970         echo "Looking for ${cf_ncuconfig_root}-config"
1971
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)])
1975
1976         if test "$NCURSES_CONFIG" != none ; then
1977
1978                 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1979                 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
1980
1981                 # even with config script, some packages use no-override for curses.h
1982                 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
1983
1984                 dnl like CF_NCURSES_CPPFLAGS
1985                 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1986
1987                 dnl like CF_NCURSES_LIBS
1988                 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1989                 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1990
1991                 dnl like CF_NCURSES_VERSION
1992                 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1993
1994         else
1995
1996                 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1997                 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1998
1999         fi
2000 else
2001         NCURSES_CONFIG=none
2002 fi
2003 ])dnl
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.
2009 dnl
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
2017 dnl the header.
2018 dnl
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>.
2022 dnl
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])
2028
2029 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2030 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2031
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)
2035 }
2036
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
2041         do
2042                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2043                 test "$cf_cv_ncurses_h" != no && break
2044         done
2045 ])
2046
2047 CF_NCURSES_HEADER
2048 CF_TERM_HEADER
2049
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])
2052
2053 CF_NCURSES_VERSION
2054 ])dnl
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
2060 dnl if it is valid.
2061 AC_DEFUN([CF_NCURSES_EXT_FUNCS],
2062 [
2063 AC_CACHE_CHECK(for ncurses extended functions,cf_cv_ncurses_ext_funcs,[
2064 AC_TRY_COMPILE([
2065 #include <${cf_cv_ncurses_header:-curses.h}>],
2066 [
2067 int x = NCURSES_EXT_FUNCS
2068 ],[cf_cv_ncurses_ext_funcs=defined],[
2069 AC_TRY_LINK([
2070 #include <${cf_cv_ncurses_header:-curses.h}>],
2071 [
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])
2086 ])
2087 ])
2088 test "$cf_cv_ncurses_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS,1,[Define to 1 if we have ncurses extensions])
2089 ])dnl
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.
2095 dnl
2096 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2097 AC_DEFUN([CF_NCURSES_HEADER],[
2098
2099 if test "$cf_cv_ncurses_h" != no ; then
2100         cf_cv_ncurses_header=$cf_cv_ncurses_h
2101 else
2102
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
2109         do
2110                 CF_ADD_INCDIR($cf_incdir)
2111                 for cf_header in \
2112                         ncurses.h \
2113                         curses.h
2114                 do
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
2119                                 break
2120                         fi
2121                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2122                 done
2123                 CPPFLAGS="$cf_save2_CPPFLAGS"
2124                 test "$cf_cv_ncurses_h2" != no && break
2125         done
2126         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2127         ])
2128
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
2133         fi
2134         CF_ADD_INCDIR($cf_1st_incdir)
2135
2136 fi
2137
2138 # Set definitions to allow ifdef'ing for ncurses.h
2139
2140 case $cf_cv_ncurses_header in
2141 (*ncurses.h)
2142         AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
2143         ;;
2144 esac
2145
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])
2149         ;;
2150 (ncursesw/curses.h|ncursesw/ncurses.h)
2151         AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2152         ;;
2153 esac
2154
2155 ])dnl
2156 dnl ---------------------------------------------------------------------------
2157 dnl CF_NCURSES_LIBS version: 17 updated: 2015/04/15 19:08:48
2158 dnl ---------------
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.
2165 dnl
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])
2171
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
2175         # to link gpm.
2176 cf_ncurses_LIBS=""
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"])])
2182
2183 case $host_os in
2184 (freebsd*)
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"])
2189         fi
2190         ;;
2191 esac
2192
2193 CF_ADD_LIBS($cf_ncurses_LIBS)
2194
2195 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2196 then
2197         CF_ADD_LIBS(-l$cf_nculib_root)
2198 else
2199         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2200                 [#include <${cf_cv_ncurses_header:-curses.h}>],
2201                 [initscr()],
2202                 initscr)
2203 fi
2204
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
2211                         LIBS="$q"
2212                 fi
2213         done
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)],
2217                 [AC_MSG_RESULT(no)
2218                  LIBS="$cf_ncurses_SAVE"])
2219 fi
2220
2221 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2222 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2223 ])dnl
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],
2231 [
2232 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2233 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2234         cf_cv_ncurses_version=no
2235         cf_tempfile=out$$
2236         rm -f $cf_tempfile
2237         AC_TRY_RUN([
2238 #include <${cf_cv_ncurses_header:-curses.h}>
2239 #include <stdio.h>
2240 int main()
2241 {
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);
2246 # else
2247         fprintf(fp, "%s\n", NCURSES_VERSION);
2248 # endif
2249 #else
2250 # ifdef __NCURSES_H
2251         fprintf(fp, "old\n");
2252 # else
2253         make an error
2254 # endif
2255 #endif
2256         ${cf_cv_main_return:-return}(0);
2257 }],[
2258         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2259
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}>
2264 #undef Autoconf
2265 #ifdef NCURSES_VERSION
2266 Autoconf NCURSES_VERSION
2267 #else
2268 #ifdef __NCURSES_H
2269 Autoconf "old"
2270 #endif
2271 ;
2272 #endif
2273 EOF
2274         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2275         AC_TRY_EVAL(cf_try)
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"
2279                 rm -f conftest.out
2280         fi
2281 ])
2282         rm -f $cf_tempfile
2283 ])
2284 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2285 ])dnl
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],
2292 [
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)
2299
2300 AC_SUBST(NCURSES_WRAP_PREFIX)
2301 ])
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,[
2309 AC_TRY_COMPILE([
2310 #include <${cf_cv_ncurses_header:-curses.h}>
2311 #include <form.h>
2312 ],[
2313         FORM *form;
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])
2318 ])
2319
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])
2321 ])dnl
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,[
2329 AC_TRY_COMPILE([
2330 #include <${cf_cv_ncurses_header:-curses.h}>
2331 #include <menu.h>
2332 ],[
2333         MENU *menu;
2334         int y = menu->max_item_width;
2335 ],[cf_cv_netbsd_menu_h=yes
2336 ],[cf_cv_netbsd_menu_h=no])
2337 ])
2338
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])
2340 ])dnl
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)
2347 AC_ARG_WITH($1,
2348         [$2],
2349         [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
2350          $4
2351 ])
2352         : ${with_cflags:=-g}
2353         : ${with_no_leaks:=yes}
2354          with_$1=yes],
2355         [with_$1=])
2356 AC_MSG_RESULT(${with_$1:-no})
2357
2358 case .$with_cflags in
2359 (.*-g*)
2360         case .$CFLAGS in
2361         (.*-g*)
2362                 ;;
2363         (*)
2364                 CF_ADD_CFLAGS([-g])
2365                 ;;
2366         esac
2367         ;;
2368 esac
2369 ])dnl
2370 dnl ---------------------------------------------------------------------------
2371 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
2372 dnl --------------
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"
2380 else
2381         cf_path_syntax="$ac_default_prefix"
2382 fi
2383
2384 case ".[$]$1" in
2385 (.\[$]\(*\)*|.\'*\'*)
2386         ;;
2387 (..|./*|.\\*)
2388         ;;
2389 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
2390         ;;
2391 (.\[$]{*prefix}*|.\[$]{*dir}*)
2392         eval $1="[$]$1"
2393         case ".[$]$1" in
2394         (.NONE/*)
2395                 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2396                 ;;
2397         esac
2398         ;;
2399 (.no|.NONE/*)
2400         $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2401         ;;
2402 (*)
2403         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2404         ;;
2405 esac
2406 ])dnl
2407 dnl ---------------------------------------------------------------------------
2408 dnl CF_PDCURSES_X11 version: 13 updated: 2012/10/06 16:39:58
2409 dnl ---------------
2410 dnl Configure for PDCurses' X11 library
2411 AC_DEFUN([CF_PDCURSES_X11],[
2412 AC_REQUIRE([CF_X_ATHENA])
2413
2414 CF_ACVERSION_CHECK(2.52,
2415         [AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
2416         [AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
2417
2418 if test "$XCURSES_CONFIG" != none ; then
2419
2420 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
2421 CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
2422
2423 cf_cv_lib_XCurses=yes
2424
2425 else
2426
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)
2434 AC_TRY_LINK([
2435 #include <xcurses.h>
2436 char *XCursesProgramName = "test";
2437 ],[XCursesExit();],
2438 [cf_cv_lib_XCurses=yes],
2439 [cf_cv_lib_XCurses=no])
2440 ])
2441
2442 fi
2443
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]))
2448 else
2449         AC_MSG_ERROR(Cannot link with XCurses)
2450 fi
2451 ])dnl
2452 dnl ---------------------------------------------------------------------------
2453 dnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
2454 dnl -------------
2455 dnl Check for the package-config program, unless disabled by command-line.
2456 AC_DEFUN([CF_PKG_CONFIG],
2457 [
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)
2464
2465 case $cf_pkg_config in
2466 (no)
2467         PKG_CONFIG=none
2468         ;;
2469 (yes)
2470         CF_ACVERSION_CHECK(2.52,
2471                 [AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
2472                 [AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
2473         ;;
2474 (*)
2475         PKG_CONFIG=$withval
2476         ;;
2477 esac
2478
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)
2484 fi
2485
2486 AC_SUBST(PKG_CONFIG)
2487 ])dnl
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.
2492 dnl
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
2496 dnl             Bindings Option
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
2500 dnl
2501 dnl Parameters:
2502 dnl     $1 is the nominal value for _POSIX_C_SOURCE
2503 AC_DEFUN([CF_POSIX_C_SOURCE],
2504 [
2505 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2506
2507 cf_save_CFLAGS="$CFLAGS"
2508 cf_save_CPPFLAGS="$CPPFLAGS"
2509
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)
2512
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
2517 make an error
2518 #endif],
2519         [cf_cv_posix_c_source=no],
2520         [cf_want_posix_source=no
2521          case .$cf_POSIX_C_SOURCE in
2522          (.[[12]]??*)
2523                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2524                 ;;
2525          (.2)
2526                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2527                 cf_want_posix_source=yes
2528                 ;;
2529          (.*)
2530                 cf_want_posix_source=yes
2531                 ;;
2532          esac
2533          if test "$cf_want_posix_source" = yes ; then
2534                 AC_TRY_COMPILE([#include <sys/types.h>],[
2535 #ifdef _POSIX_SOURCE
2536 make an error
2537 #endif],[],
2538                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2539          fi
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
2546 make an error
2547 #endif],,
2548          [cf_cv_posix_c_source=no])
2549          CFLAGS="$cf_save_CFLAGS"
2550          CPPFLAGS="$cf_save_CPPFLAGS"
2551         ])
2552 ])
2553
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)
2558 fi
2559
2560 ])dnl
2561 dnl ---------------------------------------------------------------------------
2562 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
2563 dnl ------------
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.
2566 dnl
2567 dnl parameters
2568 dnl     $1 = script to run
2569 dnl     $2 = list of subdirectories
2570 dnl
2571 dnl variables
2572 dnl     $AWK
2573 AC_DEFUN([CF_PRG_RULES],
2574 [
2575 for cf_dir in $2
2576 do
2577         if test ! -d $srcdir/$cf_dir; then
2578                 continue
2579         elif test -f $srcdir/$cf_dir/programs; then
2580                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
2581         fi
2582 done
2583
2584 ])dnl
2585 dnl ---------------------------------------------------------------------------
2586 dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
2587 dnl ----------
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)])
2592 CF_GCC_VERSION
2593 CF_ACVERSION_CHECK(2.52,
2594         [AC_PROG_CC_STDC],
2595         [CF_ANSI_CC_REQD])
2596 CF_CC_ENV_FLAGS
2597 ])dnl
2598 dnl ---------------------------------------------------------------------------
2599 dnl CF_PROG_INSTALL version: 7 updated: 2015/04/18 08:56:57
2600 dnl ---------------
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],
2605 [AC_PROG_INSTALL
2606 case $INSTALL in
2607 (/*)
2608         ;;
2609 (*)
2610         CF_DIRNAME(cf_dir,$INSTALL)
2611         test -z "$cf_dir" && cf_dir=.
2612         INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
2613         ;;
2614 esac
2615 ])dnl
2616 dnl ---------------------------------------------------------------------------
2617 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
2618 dnl ------------
2619 AC_DEFUN([CF_PROG_LINT],
2620 [
2621 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
2622 AC_SUBST(LINT_OPTS)
2623 ])dnl
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.
2631 dnl
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],
2636 [
2637 $1=`echo "$2" | \
2638         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
2639                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
2640 ])dnl
2641 dnl ---------------------------------------------------------------------------
2642 dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
2643 dnl -------------
2644 AC_DEFUN([CF_RPATH_HACK],
2645 [
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)
2650
2651         AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2652         cf_rpath_list="/usr/lib /lib"
2653         if test "$cf_ldd_prog" != no
2654         then
2655                 cf_rpath_oops=
2656
2657 AC_TRY_LINK([#include <stdio.h>],
2658                 [printf("Hello");],
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`])
2661
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"
2668                 then
2669                         for cf_rpath_src in $cf_rpath_oops
2670                         do
2671                                 for cf_rpath_dir in \
2672                                         /usr/local \
2673                                         /usr/pkg \
2674                                         /opt/sfw
2675                                 do
2676                                         if test -f $cf_rpath_dir/lib/$cf_rpath_src
2677                                         then
2678                                                 CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2679                                                 LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2680                                                 break
2681                                         fi
2682                                 done
2683                         done
2684                 fi
2685         fi
2686
2687         CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2688
2689         CF_RPATH_HACK_2(LDFLAGS)
2690         CF_RPATH_HACK_2(LIBS)
2691
2692         CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2693 else
2694         AC_MSG_RESULT(no)
2695 fi
2696 AC_SUBST(EXTRA_LDFLAGS)
2697 ])dnl
2698 dnl ---------------------------------------------------------------------------
2699 dnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
2700 dnl ---------------
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.
2703 dnl
2704 dnl $cf_rpath_list contains a list of directories to ignore.
2705 dnl
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],
2709 [
2710 CF_VERBOSE(...checking $1 [$]$1)
2711
2712 cf_rpath_dst=
2713 for cf_rpath_src in [$]$1
2714 do
2715         case $cf_rpath_src in
2716         (-L*)
2717
2718                 # check if this refers to a directory which we will ignore
2719                 cf_rpath_skip=no
2720                 if test -n "$cf_rpath_list"
2721                 then
2722                         for cf_rpath_item in $cf_rpath_list
2723                         do
2724                                 if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2725                                 then
2726                                         cf_rpath_skip=yes
2727                                         break
2728                                 fi
2729                         done
2730                 fi
2731
2732                 if test "$cf_rpath_skip" = no
2733                 then
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 %"`
2737                         else
2738                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2739                         fi
2740
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"
2744                         then
2745                                 CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2746                                 EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2747                         fi
2748                 fi
2749                 ;;
2750         esac
2751         cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2752 done
2753 $1=$cf_rpath_dst
2754
2755 CF_VERBOSE(...checked $1 [$]$1)
2756 AC_SUBST(EXTRA_LDFLAGS)
2757 ])dnl
2758 dnl ---------------------------------------------------------------------------
2759 dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2760 dnl ---------------
2761 dnl signal handler, but there are some gcc depedencies in that recommendation.
2762 dnl Try anyway.
2763 AC_DEFUN([CF_SIG_ATOMIC_T],
2764 [
2765 AC_MSG_CHECKING(for signal global datatype)
2766 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2767         for cf_type in \
2768                 "volatile sig_atomic_t" \
2769                 "sig_atomic_t" \
2770                 "int"
2771         do
2772         AC_TRY_COMPILE([
2773 #include <sys/types.h>
2774 #include <signal.h>
2775 #include <stdio.h>
2776
2777 extern $cf_type x;
2778 $cf_type x;
2779 static void handler(int sig)
2780 {
2781         x = 5;
2782 }],
2783                 [signal(SIGINT, handler);
2784                  x = 1],
2785                 [cf_cv_sig_atomic_t=$cf_type],
2786                 [cf_cv_sig_atomic_t=no])
2787                 test "$cf_cv_sig_atomic_t" != no && break
2788         done
2789         ])
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])
2792 ])dnl
2793 dnl ---------------------------------------------------------------------------
2794 dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
2795 dnl --------------
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],
2801 [
2802 $1=
2803
2804 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
2805
2806 for cf_subdir_prefix in \
2807         /usr \
2808         /usr/local \
2809         /usr/pkg \
2810         /opt \
2811         /opt/local \
2812         [$]HOME
2813 do
2814         CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
2815 done
2816 ])dnl
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],
2823 [
2824 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2825 AC_CACHE_VAL(cf_cv_sys_time_select,[
2826 AC_TRY_COMPILE([
2827 #include <sys/types.h>
2828 #ifdef HAVE_SYS_TIME_H
2829 #include <sys/time.h>
2830 #endif
2831 #ifdef HAVE_SYS_SELECT_H
2832 #include <sys/select.h>
2833 #endif
2834 ],[],[cf_cv_sys_time_select=yes],
2835          [cf_cv_sys_time_select=no])
2836          ])
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>])
2839 ])dnl
2840 dnl ---------------------------------------------------------------------------
2841 dnl CF_TERM_HEADER version: 4 updated: 2015/04/15 19:08:48
2842 dnl --------------
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%'`
2851         ;;
2852 (*)
2853         cf_term_header=term.h
2854         ;;
2855 esac
2856
2857 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2858 do
2859 AC_TRY_COMPILE([#include <stdio.h>
2860 #include <${cf_cv_ncurses_header:-curses.h}>
2861 #include <$cf_test>
2862 ],[int x = auto_left_margin],[
2863         cf_cv_term_header="$cf_test"],[
2864         cf_cv_term_header=unknown
2865         ])
2866         test "$cf_cv_term_header" != unknown && break
2867 done
2868 ])
2869
2870 # Set definitions to allow ifdef'ing to accommodate subdirectories
2871
2872 case $cf_cv_term_header in
2873 (*term.h)
2874         AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
2875         ;;
2876 esac
2877
2878 case $cf_cv_term_header in
2879 (ncurses/term.h)
2880         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
2881         ;;
2882 (ncursesw/term.h)
2883         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
2884         ;;
2885 esac
2886 ])dnl
2887 dnl ---------------------------------------------------------------------------
2888 dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
2889 dnl ---------------
2890 dnl Define a top_builddir symbol, for applications that need an absolute path.
2891 AC_DEFUN([CF_TOP_BUILDDIR],
2892 [
2893 top_builddir=ifelse($1,,`pwd`,$1)
2894 AC_SUBST(top_builddir)
2895 ])dnl
2896 dnl ---------------------------------------------------------------------------
2897 dnl CF_TPUTS_PROTO version: 3 updated: 2015/04/17 21:26:14
2898 dnl --------------
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
2905 then
2906         cf_done=no
2907         for cf_arg in int char
2908         do
2909                 for cf_ret in int void
2910                 do
2911                         if test $cf_ret = void
2912                         then
2913                                 cf_return="/* nothing */"
2914                         else
2915                                 cf_return="return value"
2916                         fi
2917                         AC_TRY_COMPILE([
2918 #include <${cf_cv_ncurses_header:-curses.h}>
2919 #include <$cf_cv_term_header>
2920
2921 static $cf_ret outc($cf_arg value) { $cf_return; }
2922 ],[
2923         tputs("hello", 0, outc);
2924         ${cf_cv_main_return:-return}(0);
2925 ],[
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
2931 EOF
2932                 cf_done=yes
2933                 break
2934 ])
2935                 done
2936                 test $cf_done = yes && break
2937         done
2938 fi
2939 ])dnl
2940 dnl ---------------------------------------------------------------------------
2941 dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
2942 dnl --------------
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
2947         do
2948                 case "$LIBS" in
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)
2952                         ;;
2953                 esac
2954         done
2955 ])
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.
2961 dnl
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])
2967
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])
2977 else
2978         cf_pkgconfig_incs=
2979         cf_pkgconfig_libs=
2980         ifelse([$3],,:,[$3])
2981 fi
2982 ])
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,[
2990         AC_TRY_COMPILE([
2991 #include <stdlib.h>
2992 #include <string.h>
2993 #include <sys/types.h>
2994 ],[
2995 #ifndef _XOPEN_SOURCE
2996 make an error
2997 #endif],
2998         [cf_cv_xopen_source=no],
2999         [cf_save="$CPPFLAGS"
3000          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3001          AC_TRY_COMPILE([
3002 #include <stdlib.h>
3003 #include <string.h>
3004 #include <sys/types.h>
3005 ],[
3006 #ifdef _XOPEN_SOURCE
3007 make an error
3008 #endif],
3009         [cf_cv_xopen_source=no],
3010         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3011         CPPFLAGS="$cf_save"
3012         ])
3013 ])
3014
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)
3020 fi
3021 ])
3022 dnl ---------------------------------------------------------------------------
3023 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3024 dnl --------
3025 dnl Make an uppercase version of a variable
3026 dnl $1=uppercase($2)
3027 AC_DEFUN([CF_UPPER],
3028 [
3029 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3030 ])dnl
3031 dnl ---------------------------------------------------------------------------
3032 dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
3033 dnl -----------
3034 dnl Check for multibyte support, and if not found, utf8 compatibility library
3035 AC_DEFUN([CF_UTF8_LIB],
3036 [
3037 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3038         cf_save_LIBS="$LIBS"
3039         AC_TRY_LINK([
3040 #include <stdlib.h>],[putwc(0,0);],
3041         [cf_cv_utf8_lib=yes],
3042         [CF_FIND_LINKAGE([
3043 #include <libutf8.h>],[putwc(0,0);],utf8,
3044                 [cf_cv_utf8_lib=add-on],
3045                 [cf_cv_utf8_lib=no])
3046 ])])
3047
3048 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3049 # ncurses/ncursesw:
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)
3055 fi
3056 ])dnl
3057 dnl ---------------------------------------------------------------------------
3058 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3059 dnl ----------
3060 dnl Use AC_VERBOSE w/o the warnings
3061 AC_DEFUN([CF_VERBOSE],
3062 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
3063 CF_MSG_LOG([$1])
3064 ])dnl
3065 dnl ---------------------------------------------------------------------------
3066 dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
3067 dnl -------------
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
3071 dnl opposite sense.
3072 AC_DEFUN([CF_WCHAR_TYPE],
3073 [
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,[
3076 AC_TRY_COMPILE([
3077 #include <stdlib.h>
3078 #include <stdarg.h>
3079 #include <stdio.h>
3080 #ifdef HAVE_LIBUTF8_H
3081 #include <libutf8.h>
3082 #endif],
3083         [$1 state],
3084         [cf_cv_$1=no],
3085         [AC_TRY_COMPILE([
3086 #include <stdlib.h>
3087 #include <stdarg.h>
3088 #include <stdio.h>
3089 #include <wchar.h>
3090 #ifdef HAVE_LIBUTF8_H
3091 #include <libutf8.h>
3092 #endif],
3093         [$1 value],
3094         [cf_cv_$1=yes],
3095         [cf_cv_$1=unknown])])])
3096
3097 if test "$cf_cv_$1" = yes ; then
3098         AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
3099         NEED_WCHAR_H=1
3100 fi
3101
3102 ifelse([$2],,,[
3103 # if we do not find $1 in either place, use substitution to provide a fallback.
3104 if test "$cf_cv_$1" = unknown ; then
3105         $2=1
3106 fi
3107 ])
3108 ifelse($3,,,[
3109 # if we find $1 in either place, use substitution to provide a fallback.
3110 if test "$cf_cv_$1" != unknown ; then
3111         $3=1
3112 fi
3113 ])
3114 ])dnl
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
3119 dnl libraries.
3120 AC_DEFUN([CF_WITH_CURSES_DIR],[
3121
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)
3128
3129 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
3130 then
3131         CF_PATH_SYNTAX(withval)
3132         if test -d "$cf_cv_curses_dir"
3133         then
3134                 CF_ADD_INCDIR($cf_cv_curses_dir/include)
3135                 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
3136         fi
3137 fi
3138 ])dnl
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],
3147         [USE_DBMALLOC])
3148
3149 if test "$with_dbmalloc" = yes ; then
3150         AC_CHECK_HEADER(dbmalloc.h,
3151                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3152 fi
3153 ])dnl
3154 dnl ---------------------------------------------------------------------------
3155 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3156 dnl ---------------
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],
3162         [USE_DMALLOC])
3163
3164 if test "$with_dmalloc" = yes ; then
3165         AC_CHECK_HEADER(dmalloc.h,
3166                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3167 fi
3168 ])dnl
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.
3175 dnl
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],[
3179 CF_WITH_CURSES_DIR
3180
3181 cf_cv_screen=curses
3182
3183 AC_MSG_CHECKING(for specified curses library type)
3184 AC_ARG_WITH(screen,
3185         [  --with-screen=XXX       use specified curses-libraries],
3186         [cf_cv_screen=$withval],[
3187
3188 AC_ARG_WITH(ncursesw,
3189         [  --with-ncursesw         use wide ncurses-libraries],
3190         [cf_cv_screen=ncursesw],[
3191
3192 AC_ARG_WITH(ncurses,
3193         [  --with-ncurses          use ncurses-libraries],
3194         [cf_cv_screen=ncurses],[
3195
3196 AC_ARG_WITH(pdcurses,
3197         [  --with-pdcurses         compile/link with pdcurses X11 library],
3198         [cf_cv_screen=pdcurses],[
3199
3200 AC_ARG_WITH(curses-colr,
3201         [  --with-curses-colr      compile/link with HPUX 10.x color-curses],
3202         [cf_cv_screen=curses_colr],[
3203
3204 AC_ARG_WITH(curses-5lib,
3205         [  --with-curses-5lib      compile/link with SunOS 5lib curses],
3206         [cf_cv_screen=curses_5lib])])])])])])
3207
3208 AC_MSG_RESULT($cf_cv_screen)
3209
3210 case $cf_cv_screen in
3211 (curses|curses_*)
3212         CF_CURSES_CONFIG
3213         ;;
3214 (ncursesw*)
3215         CF_UTF8_LIB
3216         CF_NCURSES_CONFIG($cf_cv_screen)
3217         ;;
3218 (ncurses*)
3219         CF_NCURSES_CONFIG($cf_cv_screen)
3220         ;;
3221 (pdcurses)
3222         CF_PDCURSES_X11
3223         ;;
3224 (*)
3225         AC_MSG_ERROR(unexpected screen-value: $cf_cv_screen)
3226         ;;
3227 esac
3228
3229 ])dnl
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],
3236         [USE_VALGRIND])
3237 ])dnl
3238 dnl ---------------------------------------------------------------------------
3239 dnl CF_XOPEN_CURSES version: 11 updated: 2011/01/18 18:15:30
3240 dnl ---------------
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.
3243 dnl
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],
3247 [
3248 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3249 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
3250 AC_TRY_LINK([
3251 #include <stdlib.h>
3252 #include <${cf_cv_ncurses_header:-curses.h}>],[
3253 #if defined(NCURSES_VERSION_PATCH)
3254 #if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
3255         make an error
3256 #endif
3257 #endif
3258         long x = winnstr(stdscr, "", 0);
3259         int x1, y1;
3260         getbegyx(stdscr, y1, x1)],
3261         [cf_cv_need_xopen_extension=no],
3262         [AC_TRY_LINK([
3263 #define _XOPEN_SOURCE_EXTENDED
3264 #include <stdlib.h>
3265 #include <${cf_cv_ncurses_header:-curses.h}>],[
3266 #ifdef NCURSES_VERSION
3267         cchar_t check;
3268         int check2 = curs_set((int)sizeof(check));
3269 #endif
3270         long x = winnstr(stdscr, "", 0);
3271         int x1, y1;
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"
3276 ])dnl
3277 dnl ---------------------------------------------------------------------------
3278 dnl CF_XOPEN_SOURCE version: 49 updated: 2015/04/12 15:39:00
3279 dnl ---------------
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.
3283 dnl
3284 dnl Parameters:
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])
3289
3290 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3291 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3292 cf_xopen_source=
3293
3294 case $host_os in
3295 (aix[[4-7]]*)
3296         cf_xopen_source="-D_ALL_SOURCE"
3297         ;;
3298 (cygwin|msys)
3299         cf_XOPEN_SOURCE=600
3300         ;;
3301 (darwin[[0-8]].*)
3302         cf_xopen_source="-D_APPLE_C_SOURCE"
3303         ;;
3304 (darwin*)
3305         cf_xopen_source="-D_DARWIN_C_SOURCE"
3306         cf_XOPEN_SOURCE=
3307         ;;
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
3313         cf_XOPEN_SOURCE=600
3314         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3315         ;;
3316 (hpux11*)
3317         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3318         ;;
3319 (hpux*)
3320         cf_xopen_source="-D_HPUX_SOURCE"
3321         ;;
3322 (irix[[56]].*)
3323         cf_xopen_source="-D_SGI_SOURCE"
3324         cf_XOPEN_SOURCE=
3325         ;;
3326 (linux*|gnu*|mint*|k*bsd*-gnu)
3327         CF_GNU_SOURCE
3328         ;;
3329 (minix*)
3330         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
3331         ;;
3332 (mirbsd*)
3333         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
3334         cf_XOPEN_SOURCE=
3335         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3336         ;;
3337 (netbsd*)
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
3339         ;;
3340 (openbsd[[4-9]]*)
3341         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
3342         cf_xopen_source="-D_BSD_SOURCE"
3343         cf_XOPEN_SOURCE=600
3344         ;;
3345 (openbsd*)
3346         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3347         ;;
3348 (osf[[45]]*)
3349         cf_xopen_source="-D_OSF_SOURCE"
3350         ;;
3351 (nto-qnx*)
3352         cf_xopen_source="-D_QNX_SOURCE"
3353         ;;
3354 (sco*)
3355         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3356         ;;
3357 (solaris2.*)
3358         cf_xopen_source="-D__EXTENSIONS__"
3359         cf_cv_xopen_source=broken
3360         ;;
3361 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
3362         cf_XOPEN_SOURCE=
3363         cf_POSIX_C_SOURCE=
3364         ;;
3365 (*)
3366         CF_TRY_XOPEN_SOURCE
3367         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3368         ;;
3369 esac
3370
3371 if test -n "$cf_xopen_source" ; then
3372         CF_ADD_CFLAGS($cf_xopen_source,true)
3373 fi
3374
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
3382 make an error
3383 #endif],
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
3388         then
3389                 AC_TRY_COMPILE([#include <stdlib.h>],[
3390 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
3391 make an error
3392 #endif],
3393                 [cf_XOPEN_SOURCE_set_ok=yes],
3394                 [cf_XOPEN_SOURCE_set_ok=no])
3395                 if test $cf_XOPEN_SOURCE_set_ok = no
3396                 then
3397                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
3398                 fi
3399         else
3400                 CF_TRY_XOPEN_SOURCE
3401         fi
3402 fi
3403 ])
3404 dnl ---------------------------------------------------------------------------
3405 dnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
3406 dnl -----------
3407 dnl Check for Xaw (Athena) libraries
3408 dnl
3409 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
3410 AC_DEFUN([CF_X_ATHENA],
3411 [
3412 cf_x_athena=${cf_x_athena:-Xaw}
3413
3414 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
3415 withval=
3416 AC_ARG_WITH(Xaw3d,
3417         [  --with-Xaw3d            link with Xaw 3d library])
3418 if test "$withval" = yes ; then
3419         cf_x_athena=Xaw3d
3420         AC_MSG_RESULT(yes)
3421 else
3422         AC_MSG_RESULT(no)
3423 fi
3424
3425 AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
3426 withval=
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
3431         AC_MSG_RESULT(yes)
3432 else
3433         AC_MSG_RESULT(no)
3434 fi
3435
3436 AC_MSG_CHECKING(if you want to link with neXT Athena library)
3437 withval=
3438 AC_ARG_WITH(neXtaw,
3439         [  --with-neXtaw           link with neXT Athena library])
3440 if test "$withval" = yes ; then
3441         cf_x_athena=neXtaw
3442         AC_MSG_RESULT(yes)
3443 else
3444         AC_MSG_RESULT(no)
3445 fi
3446
3447 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
3448 withval=
3449 AC_ARG_WITH(XawPlus,
3450         [  --with-XawPlus          link with Athena-Plus library])
3451 if test "$withval" = yes ; then
3452         cf_x_athena=XawPlus
3453         AC_MSG_RESULT(yes)
3454 else
3455         AC_MSG_RESULT(no)
3456 fi
3457
3458 cf_x_athena_lib=""
3459
3460 if test "$PKG_CONFIG" != none ; then
3461         cf_athena_list=
3462         test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
3463         for cf_athena_pkg in \
3464                 $cf_athena_list \
3465                 ${cf_x_athena} \
3466                 ${cf_x_athena}-devel \
3467                 lib${cf_x_athena} \
3468                 lib${cf_x_athena}-devel
3469         do
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)
3474
3475                         CF_TRIM_X_LIBS
3476
3477 AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
3478 AC_TRY_LINK([
3479 #include <X11/Xmu/CharSet.h>
3480 ],[
3481 int check = XmuCompareISOLatin1("big", "small")
3482 ],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
3483
3484                         if test "$cf_cv_xaw_compat" = no
3485                         then
3486                                 # workaround for broken ".pc" files...
3487                                 case "$cf_x_athena_lib" in
3488                                 (*-lXmu*)
3489                                         ;;
3490                                 (*)
3491                                         CF_VERBOSE(work around broken package)
3492                                         cf_save_xmu="$LIBS"
3493                                         cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
3494                                         CF_TRY_PKG_CONFIG(xmu,[
3495                                                         LIBS="$cf_save_xmu"
3496                                                         CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
3497                                                 ],[
3498                                                         CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
3499                                                 ])
3500                                         CF_TRIM_X_LIBS
3501                                         ;;
3502                                 esac
3503                         fi
3504
3505                         break])
3506         done
3507 fi
3508
3509 if test -z "$cf_x_athena_lib" ; then
3510         CF_X_EXT
3511         CF_X_TOOLKIT
3512         CF_X_ATHENA_CPPFLAGS($cf_x_athena)
3513         CF_X_ATHENA_LIBS($cf_x_athena)
3514 fi
3515 ])dnl
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],
3522 [
3523 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3524 cf_x_athena_inc=""
3525
3526 for cf_path in default \
3527         /usr/contrib/X11R6 \
3528         /usr/contrib/X11R5 \
3529         /usr/lib/X11R5 \
3530         /usr/local
3531 do
3532         if test -z "$cf_x_athena_inc" ; then
3533                 cf_save="$CPPFLAGS"
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)
3538                 else
3539                         AC_MSG_CHECKING(for $cf_test)
3540                 fi
3541                 AC_TRY_COMPILE([
3542 #include <X11/Intrinsic.h>
3543 #include <$cf_test>],[],
3544                         [cf_result=yes],
3545                         [cf_result=no])
3546                 AC_MSG_RESULT($cf_result)
3547                 if test "$cf_result" = yes ; then
3548                         cf_x_athena_inc=$cf_path
3549                         break
3550                 else
3551                         CPPFLAGS="$cf_save"
3552                 fi
3553         fi
3554 done
3555
3556 if test -z "$cf_x_athena_inc" ; then
3557         AC_MSG_WARN(
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"
3561 fi
3562 ])
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])
3571 cf_x_athena_lib=""
3572
3573 for cf_path in default \
3574         /usr/contrib/X11R6 \
3575         /usr/contrib/X11R5 \
3576         /usr/lib/X11R5 \
3577         /usr/local
3578 do
3579         for cf_lib in \
3580                 ${cf_x_athena_root} \
3581                 ${cf_x_athena_root}7 \
3582                 ${cf_x_athena_root}6
3583         do
3584         for cf_libs in \
3585                 "-l$cf_lib -lXmu" \
3586                 "-l$cf_lib -lXpm -lXmu" \
3587                 "-l${cf_lib}_s -lXmu_s"
3588         do
3589                 if test -z "$cf_x_athena_lib" ; then
3590                         cf_save="$LIBS"
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)
3595                         else
3596                                 CF_ADD_LIBS($cf_libs)
3597                                 AC_MSG_CHECKING(for $cf_test in $cf_libs)
3598                         fi
3599                         AC_TRY_LINK([
3600 #include <X11/Intrinsic.h>
3601 #include <X11/$cf_x_athena_root/SimpleMenu.h>
3602 ],[
3603 $cf_test((XtAppContext) 0)],
3604                                 [cf_result=yes],
3605                                 [cf_result=no])
3606                         AC_MSG_RESULT($cf_result)
3607                         if test "$cf_result" = yes ; then
3608                                 cf_x_athena_lib="$cf_libs"
3609                                 break
3610                         fi
3611                         LIBS="$cf_save"
3612                 fi
3613         done # cf_libs
3614                 test -n "$cf_x_athena_lib" && break
3615         done # cf_lib
3616 done
3617
3618 if test -z "$cf_x_athena_lib" ; then
3619         AC_MSG_ERROR(
3620 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
3621 fi
3622
3623 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3624 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3625 ])
3626 dnl ---------------------------------------------------------------------------
3627 dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
3628 dnl --------
3629 AC_DEFUN([CF_X_EXT],[
3630 CF_TRY_PKG_CONFIG(Xext,,[
3631         AC_CHECK_LIB(Xext,XextCreateExtension,
3632                 [CF_ADD_LIB(Xext)])])
3633 ])dnl
3634 dnl ---------------------------------------------------------------------------
3635 dnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
3636 dnl ------------
3637 dnl Check for X Toolkit libraries
3638 AC_DEFUN([CF_X_TOOLKIT],
3639 [
3640 AC_REQUIRE([AC_PATH_XTRA])
3641 AC_REQUIRE([CF_CHECK_CACHE])
3642
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
3647 #
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}"
3650 then
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)])
3655 fi
3656
3657 cf_have_X_LIBS=no
3658
3659 CF_TRY_PKG_CONFIG(xt,[
3660
3661         case "x$LIBS" in
3662         (*-lX11*)
3663                 ;;
3664         (*)
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,[
3667 AC_TRY_LINK([
3668 #include <X11/Xlib.h>
3669 ],[
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
3676                 then
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)])
3680                 fi
3681                 ;;
3682         esac
3683
3684 AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
3685 AC_TRY_LINK([
3686 #include <X11/Shell.h>
3687 ],[int num = IceConnectionNumber(0)
3688 ],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
3689
3690         if test "$cf_cv_xt_ice_compat" = no
3691         then
3692                 # workaround for broken ".pc" files used for X Toolkit.
3693                 case "x$X_PRE_LIBS" in
3694                 (*-lICE*)
3695                         case "x$LIBS" in
3696                         (*-lICE*)
3697                                 ;;
3698                         (*)
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)])
3703                                 ;;
3704                         esac
3705                         ;;
3706                 esac
3707         fi
3708
3709         cf_have_X_LIBS=yes
3710 ],[
3711
3712         LDFLAGS="$X_LIBS $LDFLAGS"
3713         CF_CHECK_CFLAGS($X_CFLAGS)
3714
3715         AC_CHECK_FUNC(XOpenDisplay,,[
3716         AC_CHECK_LIB(X11,XOpenDisplay,
3717                 [CF_ADD_LIB(X11)],,
3718                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3719
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])
3723                  cf_have_X_LIBS=Xt
3724                  LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
3725                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3726 ])
3727
3728 if test $cf_have_X_LIBS = no ; then
3729         AC_MSG_WARN(
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
3732 to makefile.])
3733 fi
3734 ])dnl
3735 dnl ---------------------------------------------------------------------------
3736 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
3737 dnl ---------------
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],[
3741 #ifdef HAVE_XCURSES
3742 #include <xcurses.h>
3743 char * XCursesProgramName = "test";
3744 #else
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)
3751 #include <term.h>
3752 #endif
3753 #endif
3754 ])