ncurses 5.9 - patch 20150425
[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.112 2015/04/26 00:54:24 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: 12 updated: 2015/04/24 20:52:45
1914 dnl -----------------
1915 dnl Tie together the configure-script macros for ncurses.
1916 dnl Prefer the "-config" script from ncurses 6.x, to simplify analysis.
1917 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
1918 dnl
1919 dnl $1 is the root library name (default: "ncurses")
1920 AC_DEFUN([CF_NCURSES_CONFIG],[
1921 AC_REQUIRE([CF_PKG_CONFIG])
1922 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1923 cf_have_ncuconfig=no
1924
1925 if test "x$PKG_CONFIG" != xnone; then
1926         AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
1927         if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
1928                 AC_MSG_RESULT(yes)
1929
1930                 AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
1931                 cf_have_ncuconfig=unknown
1932
1933                 cf_save_CPPFLAGS="$CPPFLAGS"
1934                 cf_save_LIBS="$LIBS"
1935
1936                 CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
1937                 CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
1938
1939                 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1940                         [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1941                         [AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
1942                                 int main(void)
1943                                 { char *xx = curses_version(); return (xx == 0); }],
1944                                 [cf_have_ncuconfig=yes],
1945                                 [cf_have_ncuconfig=no])],
1946                         [cf_have_ncuconfig=no])
1947
1948                 AC_MSG_RESULT($cf_have_ncuconfig)
1949                 if test "$cf_have_ncuconfig" != "yes"
1950                 then
1951                         CPPFLAGS="$cf_save_CPPFLAGS"
1952                         LIBS="$cf_save_LIBS"
1953                 else
1954                         AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1955                 fi
1956
1957         else
1958                 AC_MSG_RESULT(no)
1959         fi
1960 fi
1961
1962 if test "x$cf_have_ncuconfig" = "xno"; then
1963         echo "Looking for ${cf_ncuconfig_root}-config"
1964
1965         CF_ACVERSION_CHECK(2.52,
1966                 [AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
1967                 [AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
1968
1969         if test "$NCURSES_CONFIG" != none ; then
1970
1971                 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1972                 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
1973
1974                 # even with config script, some packages use no-override for curses.h
1975                 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
1976
1977                 dnl like CF_NCURSES_CPPFLAGS
1978                 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1979
1980                 dnl like CF_NCURSES_LIBS
1981                 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1982                 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1983
1984                 dnl like CF_NCURSES_VERSION
1985                 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1986
1987         else
1988
1989                 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1990                 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1991
1992         fi
1993 fi
1994 ])dnl
1995 dnl ---------------------------------------------------------------------------
1996 dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
1997 dnl -------------------
1998 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1999 dnl the CPPFLAGS variable so we can include its header.
2000 dnl
2001 dnl The header files may be installed as either curses.h, or ncurses.h (would
2002 dnl be obsolete, except that some packagers prefer this name to distinguish it
2003 dnl from a "native" curses implementation).  If not installed for overwrite,
2004 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2005 dnl /usr/include/ncurses), but someone may have installed overwriting the
2006 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2007 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2008 dnl the header.
2009 dnl
2010 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2011 dnl is already in the include-path, don't even bother with this, since we cannot
2012 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
2013 dnl
2014 dnl The optional parameter gives the root name of the library, in case it is
2015 dnl not installed as the default curses library.  That is how the
2016 dnl wide-character version of ncurses is installed.
2017 AC_DEFUN([CF_NCURSES_CPPFLAGS],
2018 [AC_REQUIRE([CF_WITH_CURSES_DIR])
2019
2020 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2021 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2022
2023 test -n "$cf_cv_curses_dir" && \
2024 test "$cf_cv_curses_dir" != "no" && { \
2025   CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2026 }
2027
2028 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2029         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2030         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2031         for cf_header in $cf_header_list
2032         do
2033                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2034                 test "$cf_cv_ncurses_h" != no && break
2035         done
2036 ])
2037
2038 CF_NCURSES_HEADER
2039 CF_TERM_HEADER
2040
2041 # some applications need this, but should check for NCURSES_VERSION
2042 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2043
2044 CF_NCURSES_VERSION
2045 ])dnl
2046 dnl ---------------------------------------------------------------------------
2047 dnl CF_NCURSES_EXT_FUNCS version: 4 updated: 2012/10/06 16:39:58
2048 dnl --------------------
2049 dnl Since 2007/11/17, ncurses has defined NCURSES_EXT_FUNCS; earlier versions
2050 dnl may provide these functions.  Define the symbol if it is not defined, and
2051 dnl if it is valid.
2052 AC_DEFUN([CF_NCURSES_EXT_FUNCS],
2053 [
2054 AC_CACHE_CHECK(for ncurses extended functions,cf_cv_ncurses_ext_funcs,[
2055 AC_TRY_COMPILE([
2056 #include <${cf_cv_ncurses_header:-curses.h}>],
2057 [
2058 int x = NCURSES_EXT_FUNCS
2059 ],[cf_cv_ncurses_ext_funcs=defined],[
2060 AC_TRY_LINK([
2061 #include <${cf_cv_ncurses_header:-curses.h}>],
2062 [
2063         (void) assume_default_colors (0, 0);
2064         (void) curses_version ();
2065         (void) define_key (0, 0);
2066         (void) is_term_resized (0, 0);
2067         (void) key_defined (0);
2068         (void) keybound (0, 0);
2069         (void) keyok (0, 0);
2070         (void) resize_term (0, 0);
2071         (void) resizeterm (0, 0);
2072         (void) use_default_colors ();
2073         (void) use_extended_names (0);
2074         (void) wresize (0, 0, 0);],
2075         [cf_cv_ncurses_ext_funcs=yes],
2076         [cf_cv_ncurses_ext_funcs=no])
2077 ])
2078 ])
2079 test "$cf_cv_ncurses_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS,1,[Define to 1 if we have ncurses extensions])
2080 ])dnl
2081 dnl ---------------------------------------------------------------------------
2082 dnl CF_NCURSES_HEADER version: 4 updated: 2015/04/15 19:08:48
2083 dnl -----------------
2084 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2085 dnl variations of ncurses' installs.
2086 dnl
2087 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2088 AC_DEFUN([CF_NCURSES_HEADER],[
2089
2090 if test "$cf_cv_ncurses_h" != no ; then
2091         cf_cv_ncurses_header=$cf_cv_ncurses_h
2092 else
2093
2094 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2095         test -n "$verbose" && echo
2096         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2097         test -n "$verbose" && echo search path $cf_search
2098         cf_save2_CPPFLAGS="$CPPFLAGS"
2099         for cf_incdir in $cf_search
2100         do
2101                 CF_ADD_INCDIR($cf_incdir)
2102                 for cf_header in \
2103                         ncurses.h \
2104                         curses.h
2105                 do
2106                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2107                         if test "$cf_cv_ncurses_h2" != no ; then
2108                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
2109                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
2110                                 break
2111                         fi
2112                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2113                 done
2114                 CPPFLAGS="$cf_save2_CPPFLAGS"
2115                 test "$cf_cv_ncurses_h2" != no && break
2116         done
2117         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2118         ])
2119
2120         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2121         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2122         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2123                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2124         fi
2125         CF_ADD_INCDIR($cf_1st_incdir)
2126
2127 fi
2128
2129 # Set definitions to allow ifdef'ing for ncurses.h
2130
2131 case $cf_cv_ncurses_header in
2132 (*ncurses.h)
2133         AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
2134         ;;
2135 esac
2136
2137 case $cf_cv_ncurses_header in
2138 (ncurses/curses.h|ncurses/ncurses.h)
2139         AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
2140         ;;
2141 (ncursesw/curses.h|ncursesw/ncurses.h)
2142         AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2143         ;;
2144 esac
2145
2146 ])dnl
2147 dnl ---------------------------------------------------------------------------
2148 dnl CF_NCURSES_LIBS version: 17 updated: 2015/04/15 19:08:48
2149 dnl ---------------
2150 dnl Look for the ncurses library.  This is a little complicated on Linux,
2151 dnl because it may be linked with the gpm (general purpose mouse) library.
2152 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2153 dnl unusable with ncurses.  However, we don't want to link with gpm unless
2154 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2155 dnl and the linker will record a dependency.
2156 dnl
2157 dnl The optional parameter gives the root name of the library, in case it is
2158 dnl not installed as the default curses library.  That is how the
2159 dnl wide-character version of ncurses is installed.
2160 AC_DEFUN([CF_NCURSES_LIBS],
2161 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2162
2163 cf_nculib_root=ifelse($1,,ncurses,$1)
2164         # This works, except for the special case where we find gpm, but
2165         # ncurses is in a nonstandard location via $LIBS, and we really want
2166         # to link gpm.
2167 cf_ncurses_LIBS=""
2168 cf_ncurses_SAVE="$LIBS"
2169 AC_CHECK_LIB(gpm,Gpm_Open,
2170         [AC_CHECK_LIB(gpm,initscr,
2171                 [LIBS="$cf_ncurses_SAVE"],
2172                 [cf_ncurses_LIBS="-lgpm"])])
2173
2174 case $host_os in
2175 (freebsd*)
2176         # This is only necessary if you are linking against an obsolete
2177         # version of ncurses (but it should do no harm, since it's static).
2178         if test "$cf_nculib_root" = ncurses ; then
2179                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2180         fi
2181         ;;
2182 esac
2183
2184 CF_ADD_LIBS($cf_ncurses_LIBS)
2185
2186 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2187 then
2188         CF_ADD_LIBS(-l$cf_nculib_root)
2189 else
2190         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2191                 [#include <${cf_cv_ncurses_header:-curses.h}>],
2192                 [initscr()],
2193                 initscr)
2194 fi
2195
2196 if test -n "$cf_ncurses_LIBS" ; then
2197         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2198         cf_ncurses_SAVE="$LIBS"
2199         for p in $cf_ncurses_LIBS ; do
2200                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2201                 if test "$q" != "$LIBS" ; then
2202                         LIBS="$q"
2203                 fi
2204         done
2205         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2206                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2207                 [AC_MSG_RESULT(yes)],
2208                 [AC_MSG_RESULT(no)
2209                  LIBS="$cf_ncurses_SAVE"])
2210 fi
2211
2212 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2213 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2214 ])dnl
2215 dnl ---------------------------------------------------------------------------
2216 dnl CF_NCURSES_VERSION version: 14 updated: 2012/10/06 08:57:51
2217 dnl ------------------
2218 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2219 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2220 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2221 AC_DEFUN([CF_NCURSES_VERSION],
2222 [
2223 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2224 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2225         cf_cv_ncurses_version=no
2226         cf_tempfile=out$$
2227         rm -f $cf_tempfile
2228         AC_TRY_RUN([
2229 #include <${cf_cv_ncurses_header:-curses.h}>
2230 #include <stdio.h>
2231 int main()
2232 {
2233         FILE *fp = fopen("$cf_tempfile", "w");
2234 #ifdef NCURSES_VERSION
2235 # ifdef NCURSES_VERSION_PATCH
2236         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2237 # else
2238         fprintf(fp, "%s\n", NCURSES_VERSION);
2239 # endif
2240 #else
2241 # ifdef __NCURSES_H
2242         fprintf(fp, "old\n");
2243 # else
2244         make an error
2245 # endif
2246 #endif
2247         ${cf_cv_main_return:-return}(0);
2248 }],[
2249         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2250
2251         # This will not work if the preprocessor splits the line after the
2252         # Autoconf token.  The 'unproto' program does that.
2253         cat > conftest.$ac_ext <<EOF
2254 #include <${cf_cv_ncurses_header:-curses.h}>
2255 #undef Autoconf
2256 #ifdef NCURSES_VERSION
2257 Autoconf NCURSES_VERSION
2258 #else
2259 #ifdef __NCURSES_H
2260 Autoconf "old"
2261 #endif
2262 ;
2263 #endif
2264 EOF
2265         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2266         AC_TRY_EVAL(cf_try)
2267         if test -f conftest.out ; then
2268                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2269                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2270                 rm -f conftest.out
2271         fi
2272 ])
2273         rm -f $cf_tempfile
2274 ])
2275 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2276 ])dnl
2277 dnl ---------------------------------------------------------------------------
2278 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
2279 dnl ----------------------
2280 dnl Check for ncurses "wrap-prefix" used for public variables which have been
2281 dnl wrapped with a function to help with concurrency control.
2282 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
2283 [
2284 AC_MSG_CHECKING(for ncurses wrap-prefix)
2285 AC_ARG_WITH(ncurses-wrap-prefix,
2286         [  --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
2287         [NCURSES_WRAP_PREFIX=$withval],
2288         [NCURSES_WRAP_PREFIX=_nc_])
2289 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
2290
2291 AC_SUBST(NCURSES_WRAP_PREFIX)
2292 ])
2293 dnl ---------------------------------------------------------------------------
2294 dnl CF_NETBSD_FORM_H version: 2 updated: 2012/10/06 16:39:58
2295 dnl ----------------
2296 dnl Check for NetBSD's form.h, which is incompatible with SVr4 and ncurses.
2297 dnl Some workarounds are needed in client programs to allow them to compile.
2298 AC_DEFUN([CF_NETBSD_FORM_H],[
2299 AC_CACHE_CHECK(for NetBSD form.h,cf_cv_netbsd_form_h,[
2300 AC_TRY_COMPILE([
2301 #include <${cf_cv_ncurses_header:-curses.h}>
2302 #include <form.h>
2303 ],[
2304         FORM *form;
2305         int y = current_field(form)->cursor_ypos;
2306         int x = current_field(form)->cursor_xpos;
2307 ],[cf_cv_netbsd_form_h=yes
2308 ],[cf_cv_netbsd_form_h=no])
2309 ])
2310
2311 test "$cf_cv_netbsd_form_h" = yes && AC_DEFINE(HAVE_NETBSD_FORM_H,1,[Define to 1 if we appear to be using NetBSD form.h])
2312 ])dnl
2313 dnl ---------------------------------------------------------------------------
2314 dnl CF_NETBSD_MENU_H version: 2 updated: 2012/10/06 16:39:58
2315 dnl ----------------
2316 dnl Check for NetBSD's menu.h, which is incompatible with SVr4 and ncurses.
2317 dnl Some workarounds are needed in client programs to allow them to compile.
2318 AC_DEFUN([CF_NETBSD_MENU_H],[
2319 AC_CACHE_CHECK(for NetBSD menu.h,cf_cv_netbsd_menu_h,[
2320 AC_TRY_COMPILE([
2321 #include <${cf_cv_ncurses_header:-curses.h}>
2322 #include <menu.h>
2323 ],[
2324         MENU *menu;
2325         int y = menu->max_item_width;
2326 ],[cf_cv_netbsd_menu_h=yes
2327 ],[cf_cv_netbsd_menu_h=no])
2328 ])
2329
2330 test "$cf_cv_netbsd_menu_h" = yes && AC_DEFINE(HAVE_NETBSD_MENU_H,1,[Define to 1 if we appear to be using NetBSD menu.h])
2331 ])dnl
2332 dnl ---------------------------------------------------------------------------
2333 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
2334 dnl ------------------
2335 dnl see CF_WITH_NO_LEAKS
2336 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2337 AC_MSG_CHECKING(if you want to use $1 for testing)
2338 AC_ARG_WITH($1,
2339         [$2],
2340         [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
2341          $4
2342 ])
2343         : ${with_cflags:=-g}
2344         : ${with_no_leaks:=yes}
2345          with_$1=yes],
2346         [with_$1=])
2347 AC_MSG_RESULT(${with_$1:-no})
2348
2349 case .$with_cflags in
2350 (.*-g*)
2351         case .$CFLAGS in
2352         (.*-g*)
2353                 ;;
2354         (*)
2355                 CF_ADD_CFLAGS([-g])
2356                 ;;
2357         esac
2358         ;;
2359 esac
2360 ])dnl
2361 dnl ---------------------------------------------------------------------------
2362 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
2363 dnl --------------
2364 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2365 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2366 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2367 dnl delayed evaluation of those symbols.
2368 AC_DEFUN([CF_PATH_SYNTAX],[
2369 if test "x$prefix" != xNONE; then
2370         cf_path_syntax="$prefix"
2371 else
2372         cf_path_syntax="$ac_default_prefix"
2373 fi
2374
2375 case ".[$]$1" in
2376 (.\[$]\(*\)*|.\'*\'*)
2377         ;;
2378 (..|./*|.\\*)
2379         ;;
2380 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
2381         ;;
2382 (.\[$]{*prefix}*|.\[$]{*dir}*)
2383         eval $1="[$]$1"
2384         case ".[$]$1" in
2385         (.NONE/*)
2386                 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2387                 ;;
2388         esac
2389         ;;
2390 (.no|.NONE/*)
2391         $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2392         ;;
2393 (*)
2394         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2395         ;;
2396 esac
2397 ])dnl
2398 dnl ---------------------------------------------------------------------------
2399 dnl CF_PDCURSES_X11 version: 13 updated: 2012/10/06 16:39:58
2400 dnl ---------------
2401 dnl Configure for PDCurses' X11 library
2402 AC_DEFUN([CF_PDCURSES_X11],[
2403 AC_REQUIRE([CF_X_ATHENA])
2404
2405 CF_ACVERSION_CHECK(2.52,
2406         [AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
2407         [AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
2408
2409 if test "$XCURSES_CONFIG" != none ; then
2410
2411 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
2412 CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
2413
2414 cf_cv_lib_XCurses=yes
2415
2416 else
2417
2418 LDFLAGS="$LDFLAGS $X_LIBS"
2419 CF_CHECK_CFLAGS($X_CFLAGS)
2420 AC_CHECK_LIB(X11,XOpenDisplay,
2421         [CF_ADD_LIBS(-lX11)],,
2422         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
2423 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
2424 CF_ADD_LIBS(-lXCurses)
2425 AC_TRY_LINK([
2426 #include <xcurses.h>
2427 char *XCursesProgramName = "test";
2428 ],[XCursesExit();],
2429 [cf_cv_lib_XCurses=yes],
2430 [cf_cv_lib_XCurses=no])
2431 ])
2432
2433 fi
2434
2435 if test $cf_cv_lib_XCurses = yes ; then
2436         AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
2437         AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
2438         AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
2439 else
2440         AC_MSG_ERROR(Cannot link with XCurses)
2441 fi
2442 ])dnl
2443 dnl ---------------------------------------------------------------------------
2444 dnl CF_PKG_CONFIG version: 9 updated: 2015/04/12 15:39:00
2445 dnl -------------
2446 dnl Check for the package-config program, unless disabled by command-line.
2447 AC_DEFUN([CF_PKG_CONFIG],
2448 [
2449 AC_MSG_CHECKING(if you want to use pkg-config)
2450 AC_ARG_WITH(pkg-config,
2451         [  --with-pkg-config{=path} enable/disable use of pkg-config],
2452         [cf_pkg_config=$withval],
2453         [cf_pkg_config=yes])
2454 AC_MSG_RESULT($cf_pkg_config)
2455
2456 case $cf_pkg_config in
2457 (no)
2458         PKG_CONFIG=none
2459         ;;
2460 (yes)
2461         CF_ACVERSION_CHECK(2.52,
2462                 [AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
2463                 [AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
2464         ;;
2465 (*)
2466         PKG_CONFIG=$withval
2467         ;;
2468 esac
2469
2470 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2471 if test "$PKG_CONFIG" != none ; then
2472         CF_PATH_SYNTAX(PKG_CONFIG)
2473 else
2474         AC_MSG_WARN(pkg-config is not installed)
2475 fi
2476
2477 AC_SUBST(PKG_CONFIG)
2478 ])dnl
2479 dnl ---------------------------------------------------------------------------
2480 dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
2481 dnl -----------------
2482 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2483 dnl
2484 dnl     POSIX.1-1990                            _POSIX_SOURCE
2485 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
2486 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
2487 dnl             Bindings Option
2488 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
2489 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
2490 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
2491 dnl
2492 dnl Parameters:
2493 dnl     $1 is the nominal value for _POSIX_C_SOURCE
2494 AC_DEFUN([CF_POSIX_C_SOURCE],
2495 [
2496 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2497
2498 cf_save_CFLAGS="$CFLAGS"
2499 cf_save_CPPFLAGS="$CPPFLAGS"
2500
2501 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2502 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2503
2504 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2505         CF_MSG_LOG(if the symbol is already defined go no further)
2506         AC_TRY_COMPILE([#include <sys/types.h>],[
2507 #ifndef _POSIX_C_SOURCE
2508 make an error
2509 #endif],
2510         [cf_cv_posix_c_source=no],
2511         [cf_want_posix_source=no
2512          case .$cf_POSIX_C_SOURCE in
2513          (.[[12]]??*)
2514                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2515                 ;;
2516          (.2)
2517                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2518                 cf_want_posix_source=yes
2519                 ;;
2520          (.*)
2521                 cf_want_posix_source=yes
2522                 ;;
2523          esac
2524          if test "$cf_want_posix_source" = yes ; then
2525                 AC_TRY_COMPILE([#include <sys/types.h>],[
2526 #ifdef _POSIX_SOURCE
2527 make an error
2528 #endif],[],
2529                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2530          fi
2531          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2532          CFLAGS="$cf_trim_CFLAGS"
2533          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2534          CF_MSG_LOG(if the second compile does not leave our definition intact error)
2535          AC_TRY_COMPILE([#include <sys/types.h>],[
2536 #ifndef _POSIX_C_SOURCE
2537 make an error
2538 #endif],,
2539          [cf_cv_posix_c_source=no])
2540          CFLAGS="$cf_save_CFLAGS"
2541          CPPFLAGS="$cf_save_CPPFLAGS"
2542         ])
2543 ])
2544
2545 if test "$cf_cv_posix_c_source" != no ; then
2546         CFLAGS="$cf_trim_CFLAGS"
2547         CPPFLAGS="$cf_trim_CPPFLAGS"
2548         CF_ADD_CFLAGS($cf_cv_posix_c_source)
2549 fi
2550
2551 ])dnl
2552 dnl ---------------------------------------------------------------------------
2553 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
2554 dnl ------------
2555 dnl Append definitions and rules for the given programs to the subdirectory
2556 dnl Makefiles, and the recursion rule for the top-level Makefile.
2557 dnl
2558 dnl parameters
2559 dnl     $1 = script to run
2560 dnl     $2 = list of subdirectories
2561 dnl
2562 dnl variables
2563 dnl     $AWK
2564 AC_DEFUN([CF_PRG_RULES],
2565 [
2566 for cf_dir in $2
2567 do
2568         if test ! -d $srcdir/$cf_dir; then
2569                 continue
2570         elif test -f $srcdir/$cf_dir/programs; then
2571                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
2572         fi
2573 done
2574
2575 ])dnl
2576 dnl ---------------------------------------------------------------------------
2577 dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
2578 dnl ----------
2579 dnl standard check for CC, plus followup sanity checks
2580 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
2581 AC_DEFUN([CF_PROG_CC],[
2582 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
2583 CF_GCC_VERSION
2584 CF_ACVERSION_CHECK(2.52,
2585         [AC_PROG_CC_STDC],
2586         [CF_ANSI_CC_REQD])
2587 CF_CC_ENV_FLAGS
2588 ])dnl
2589 dnl ---------------------------------------------------------------------------
2590 dnl CF_PROG_INSTALL version: 7 updated: 2015/04/18 08:56:57
2591 dnl ---------------
2592 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
2593 dnl misc/tabset install won't work properly.  Usually this happens only when
2594 dnl using the fallback mkinstalldirs script
2595 AC_DEFUN([CF_PROG_INSTALL],
2596 [AC_PROG_INSTALL
2597 case $INSTALL in
2598 (/*)
2599         ;;
2600 (*)
2601         CF_DIRNAME(cf_dir,$INSTALL)
2602         test -z "$cf_dir" && cf_dir=.
2603         INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
2604         ;;
2605 esac
2606 ])dnl
2607 dnl ---------------------------------------------------------------------------
2608 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
2609 dnl ------------
2610 AC_DEFUN([CF_PROG_LINT],
2611 [
2612 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
2613 AC_SUBST(LINT_OPTS)
2614 ])dnl
2615 dnl ---------------------------------------------------------------------------
2616 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2617 dnl ----------------
2618 dnl Remove all -U and -D options that refer to the given symbol from a list
2619 dnl of C compiler options.  This works around the problem that not all
2620 dnl compilers process -U and -D options from left-to-right, so a -U option
2621 dnl cannot be used to cancel the effect of a preceding -D option.
2622 dnl
2623 dnl $1 = target (which could be the same as the source variable)
2624 dnl $2 = source (including '$')
2625 dnl $3 = symbol to remove
2626 define([CF_REMOVE_DEFINE],
2627 [
2628 $1=`echo "$2" | \
2629         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
2630                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
2631 ])dnl
2632 dnl ---------------------------------------------------------------------------
2633 dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
2634 dnl -------------
2635 AC_DEFUN([CF_RPATH_HACK],
2636 [
2637 AC_REQUIRE([CF_LD_RPATH_OPT])
2638 AC_MSG_CHECKING(for updated LDFLAGS)
2639 if test -n "$LD_RPATH_OPT" ; then
2640         AC_MSG_RESULT(maybe)
2641
2642         AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2643         cf_rpath_list="/usr/lib /lib"
2644         if test "$cf_ldd_prog" != no
2645         then
2646                 cf_rpath_oops=
2647
2648 AC_TRY_LINK([#include <stdio.h>],
2649                 [printf("Hello");],
2650                 [cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2651                  cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[     ]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2652
2653                 # If we passed the link-test, but get a "not found" on a given library,
2654                 # this could be due to inept reconfiguration of gcc to make it only
2655                 # partly honor /usr/local/lib (or whatever).  Sometimes this behavior
2656                 # is intentional, e.g., installing gcc in /usr/bin and suppressing the
2657                 # /usr/local libraries.
2658                 if test -n "$cf_rpath_oops"
2659                 then
2660                         for cf_rpath_src in $cf_rpath_oops
2661                         do
2662                                 for cf_rpath_dir in \
2663                                         /usr/local \
2664                                         /usr/pkg \
2665                                         /opt/sfw
2666                                 do
2667                                         if test -f $cf_rpath_dir/lib/$cf_rpath_src
2668                                         then
2669                                                 CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2670                                                 LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2671                                                 break
2672                                         fi
2673                                 done
2674                         done
2675                 fi
2676         fi
2677
2678         CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2679
2680         CF_RPATH_HACK_2(LDFLAGS)
2681         CF_RPATH_HACK_2(LIBS)
2682
2683         CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2684 else
2685         AC_MSG_RESULT(no)
2686 fi
2687 AC_SUBST(EXTRA_LDFLAGS)
2688 ])dnl
2689 dnl ---------------------------------------------------------------------------
2690 dnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
2691 dnl ---------------
2692 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
2693 dnl EXTRA_LDFLAGS for each -L option found.
2694 dnl
2695 dnl $cf_rpath_list contains a list of directories to ignore.
2696 dnl
2697 dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
2698 dnl      but LIBS often has misplaced -L options.
2699 AC_DEFUN([CF_RPATH_HACK_2],
2700 [
2701 CF_VERBOSE(...checking $1 [$]$1)
2702
2703 cf_rpath_dst=
2704 for cf_rpath_src in [$]$1
2705 do
2706         case $cf_rpath_src in
2707         (-L*)
2708
2709                 # check if this refers to a directory which we will ignore
2710                 cf_rpath_skip=no
2711                 if test -n "$cf_rpath_list"
2712                 then
2713                         for cf_rpath_item in $cf_rpath_list
2714                         do
2715                                 if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2716                                 then
2717                                         cf_rpath_skip=yes
2718                                         break
2719                                 fi
2720                         done
2721                 fi
2722
2723                 if test "$cf_rpath_skip" = no
2724                 then
2725                         # transform the option
2726                         if test "$LD_RPATH_OPT" = "-R " ; then
2727                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
2728                         else
2729                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2730                         fi
2731
2732                         # if we have not already added this, add it now
2733                         cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
2734                         if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
2735                         then
2736                                 CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2737                                 EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2738                         fi
2739                 fi
2740                 ;;
2741         esac
2742         cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2743 done
2744 $1=$cf_rpath_dst
2745
2746 CF_VERBOSE(...checked $1 [$]$1)
2747 AC_SUBST(EXTRA_LDFLAGS)
2748 ])dnl
2749 dnl ---------------------------------------------------------------------------
2750 dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2751 dnl ---------------
2752 dnl signal handler, but there are some gcc depedencies in that recommendation.
2753 dnl Try anyway.
2754 AC_DEFUN([CF_SIG_ATOMIC_T],
2755 [
2756 AC_MSG_CHECKING(for signal global datatype)
2757 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2758         for cf_type in \
2759                 "volatile sig_atomic_t" \
2760                 "sig_atomic_t" \
2761                 "int"
2762         do
2763         AC_TRY_COMPILE([
2764 #include <sys/types.h>
2765 #include <signal.h>
2766 #include <stdio.h>
2767
2768 extern $cf_type x;
2769 $cf_type x;
2770 static void handler(int sig)
2771 {
2772         x = 5;
2773 }],
2774                 [signal(SIGINT, handler);
2775                  x = 1],
2776                 [cf_cv_sig_atomic_t=$cf_type],
2777                 [cf_cv_sig_atomic_t=no])
2778                 test "$cf_cv_sig_atomic_t" != no && break
2779         done
2780         ])
2781 AC_MSG_RESULT($cf_cv_sig_atomic_t)
2782 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2783 ])dnl
2784 dnl ---------------------------------------------------------------------------
2785 dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
2786 dnl --------------
2787 dnl Construct a search-list for a nonstandard header/lib-file
2788 dnl     $1 = the variable to return as result
2789 dnl     $2 = the package name
2790 dnl     $3 = the subdirectory, e.g., bin, include or lib
2791 AC_DEFUN([CF_SUBDIR_PATH],
2792 [
2793 $1=
2794
2795 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
2796
2797 for cf_subdir_prefix in \
2798         /usr \
2799         /usr/local \
2800         /usr/pkg \
2801         /opt \
2802         /opt/local \
2803         [$]HOME
2804 do
2805         CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
2806 done
2807 ])dnl
2808 dnl ---------------------------------------------------------------------------
2809 dnl CF_SYS_TIME_SELECT version: 6 updated: 2015/04/18 08:56:57
2810 dnl ------------------
2811 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2812 dnl older SCO configurations.
2813 AC_DEFUN([CF_SYS_TIME_SELECT],
2814 [
2815 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2816 AC_CACHE_VAL(cf_cv_sys_time_select,[
2817 AC_TRY_COMPILE([
2818 #include <sys/types.h>
2819 #ifdef HAVE_SYS_TIME_H
2820 #include <sys/time.h>
2821 #endif
2822 #ifdef HAVE_SYS_SELECT_H
2823 #include <sys/select.h>
2824 #endif
2825 ],[],[cf_cv_sys_time_select=yes],
2826          [cf_cv_sys_time_select=no])
2827          ])
2828 AC_MSG_RESULT($cf_cv_sys_time_select)
2829 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT,1,[Define to 1 if we can include <sys/time.h> with <sys/select.h>])
2830 ])dnl
2831 dnl ---------------------------------------------------------------------------
2832 dnl CF_TERM_HEADER version: 4 updated: 2015/04/15 19:08:48
2833 dnl --------------
2834 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
2835 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
2836 dnl but some packagers change this, breaking various applications.
2837 AC_DEFUN([CF_TERM_HEADER],[
2838 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2839 case ${cf_cv_ncurses_header} in
2840 (*/ncurses.h|*/ncursesw.h)
2841         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2842         ;;
2843 (*)
2844         cf_term_header=term.h
2845         ;;
2846 esac
2847
2848 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2849 do
2850 AC_TRY_COMPILE([#include <stdio.h>
2851 #include <${cf_cv_ncurses_header:-curses.h}>
2852 #include <$cf_test>
2853 ],[int x = auto_left_margin],[
2854         cf_cv_term_header="$cf_test"],[
2855         cf_cv_term_header=unknown
2856         ])
2857         test "$cf_cv_term_header" != unknown && break
2858 done
2859 ])
2860
2861 # Set definitions to allow ifdef'ing to accommodate subdirectories
2862
2863 case $cf_cv_term_header in
2864 (*term.h)
2865         AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
2866         ;;
2867 esac
2868
2869 case $cf_cv_term_header in
2870 (ncurses/term.h)
2871         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
2872         ;;
2873 (ncursesw/term.h)
2874         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
2875         ;;
2876 esac
2877 ])dnl
2878 dnl ---------------------------------------------------------------------------
2879 dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
2880 dnl ---------------
2881 dnl Define a top_builddir symbol, for applications that need an absolute path.
2882 AC_DEFUN([CF_TOP_BUILDDIR],
2883 [
2884 top_builddir=ifelse($1,,`pwd`,$1)
2885 AC_SUBST(top_builddir)
2886 ])dnl
2887 dnl ---------------------------------------------------------------------------
2888 dnl CF_TPUTS_PROTO version: 3 updated: 2015/04/17 21:26:14
2889 dnl --------------
2890 dnl Check for type of function-pointer passed to tputs.  Some old
2891 dnl implementations used functions that had different prototypes, making it
2892 dnl hard to compile portable programs using tputs.
2893 AC_DEFUN([CF_TPUTS_PROTO],[
2894 CF_CURSES_FUNCS(tputs)
2895 if test x$cf_cv_func_tputs = xyes
2896 then
2897         cf_done=no
2898         for cf_arg in int char
2899         do
2900                 for cf_ret in int void
2901                 do
2902                         if test $cf_ret = void
2903                         then
2904                                 cf_return="/* nothing */"
2905                         else
2906                                 cf_return="return value"
2907                         fi
2908                         AC_TRY_COMPILE([
2909 #include <${cf_cv_ncurses_header:-curses.h}>
2910 #include <$cf_cv_term_header>
2911
2912 static $cf_ret outc($cf_arg value) { $cf_return; }
2913 ],[
2914         tputs("hello", 0, outc);
2915         ${cf_cv_main_return:-return}(0);
2916 ],[
2917                 CF_VERBOSE([prototype $cf_ret func($cf_arg value)])
2918                 cat >>confdefs.h <<EOF
2919 #define TPUTS_ARG               $cf_arg
2920 #define TPUTS_PROTO(func,value) $cf_ret func(TPUTS_ARG value)
2921 #define TPUTS_RETURN(value)     $cf_return
2922 EOF
2923                 cf_done=yes
2924                 break
2925 ])
2926                 done
2927                 test $cf_done = yes && break
2928         done
2929 fi
2930 ])dnl
2931 dnl ---------------------------------------------------------------------------
2932 dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
2933 dnl --------------
2934 dnl Trim extra base X libraries added as a workaround for inconsistent library
2935 dnl dependencies returned by "new" pkg-config files.
2936 AC_DEFUN([CF_TRIM_X_LIBS],[
2937         for cf_trim_lib in Xmu Xt X11
2938         do
2939                 case "$LIBS" in
2940                 (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
2941                         LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
2942                         CF_VERBOSE(..trimmed $LIBS)
2943                         ;;
2944                 esac
2945         done
2946 ])
2947 dnl ---------------------------------------------------------------------------
2948 dnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
2949 dnl -----------------
2950 dnl This is a simple wrapper to use for pkg-config, for libraries which may be
2951 dnl available in that form.
2952 dnl
2953 dnl $1 = package name
2954 dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
2955 dnl $3 = logic to use if pkg-config does not have the package
2956 AC_DEFUN([CF_TRY_PKG_CONFIG],[
2957 AC_REQUIRE([CF_PKG_CONFIG])
2958
2959 if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
2960         CF_VERBOSE(found package $1)
2961         cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
2962         cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
2963         CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
2964         CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
2965         CF_ADD_CFLAGS($cf_pkgconfig_incs)
2966         CF_ADD_LIBS($cf_pkgconfig_libs)
2967         ifelse([$2],,:,[$2])
2968 else
2969         cf_pkgconfig_incs=
2970         cf_pkgconfig_libs=
2971         ifelse([$3],,:,[$3])
2972 fi
2973 ])
2974 dnl ---------------------------------------------------------------------------
2975 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
2976 dnl -------------------
2977 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
2978 dnl can define it successfully.
2979 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
2980 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2981         AC_TRY_COMPILE([
2982 #include <stdlib.h>
2983 #include <string.h>
2984 #include <sys/types.h>
2985 ],[
2986 #ifndef _XOPEN_SOURCE
2987 make an error
2988 #endif],
2989         [cf_cv_xopen_source=no],
2990         [cf_save="$CPPFLAGS"
2991          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2992          AC_TRY_COMPILE([
2993 #include <stdlib.h>
2994 #include <string.h>
2995 #include <sys/types.h>
2996 ],[
2997 #ifdef _XOPEN_SOURCE
2998 make an error
2999 #endif],
3000         [cf_cv_xopen_source=no],
3001         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3002         CPPFLAGS="$cf_save"
3003         ])
3004 ])
3005
3006 if test "$cf_cv_xopen_source" != no ; then
3007         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3008         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3009         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3010         CF_ADD_CFLAGS($cf_temp_xopen_source)
3011 fi
3012 ])
3013 dnl ---------------------------------------------------------------------------
3014 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3015 dnl --------
3016 dnl Make an uppercase version of a variable
3017 dnl $1=uppercase($2)
3018 AC_DEFUN([CF_UPPER],
3019 [
3020 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3021 ])dnl
3022 dnl ---------------------------------------------------------------------------
3023 dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
3024 dnl -----------
3025 dnl Check for multibyte support, and if not found, utf8 compatibility library
3026 AC_DEFUN([CF_UTF8_LIB],
3027 [
3028 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3029         cf_save_LIBS="$LIBS"
3030         AC_TRY_LINK([
3031 #include <stdlib.h>],[putwc(0,0);],
3032         [cf_cv_utf8_lib=yes],
3033         [CF_FIND_LINKAGE([
3034 #include <libutf8.h>],[putwc(0,0);],utf8,
3035                 [cf_cv_utf8_lib=add-on],
3036                 [cf_cv_utf8_lib=no])
3037 ])])
3038
3039 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3040 # ncurses/ncursesw:
3041 if test "$cf_cv_utf8_lib" = "add-on" ; then
3042         AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
3043         CF_ADD_INCDIR($cf_cv_header_path_utf8)
3044         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3045         CF_ADD_LIBS($cf_cv_library_file_utf8)
3046 fi
3047 ])dnl
3048 dnl ---------------------------------------------------------------------------
3049 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3050 dnl ----------
3051 dnl Use AC_VERBOSE w/o the warnings
3052 AC_DEFUN([CF_VERBOSE],
3053 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
3054 CF_MSG_LOG([$1])
3055 ])dnl
3056 dnl ---------------------------------------------------------------------------
3057 dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
3058 dnl -------------
3059 dnl Check if type wide-character type $1 is declared, and if so, which header
3060 dnl file is needed.  The second parameter is used to set a shell variable when
3061 dnl the type is not found.  The first parameter sets a shell variable for the
3062 dnl opposite sense.
3063 AC_DEFUN([CF_WCHAR_TYPE],
3064 [
3065 # This is needed on Tru64 5.0 to declare $1
3066 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
3067 AC_TRY_COMPILE([
3068 #include <stdlib.h>
3069 #include <stdarg.h>
3070 #include <stdio.h>
3071 #ifdef HAVE_LIBUTF8_H
3072 #include <libutf8.h>
3073 #endif],
3074         [$1 state],
3075         [cf_cv_$1=no],
3076         [AC_TRY_COMPILE([
3077 #include <stdlib.h>
3078 #include <stdarg.h>
3079 #include <stdio.h>
3080 #include <wchar.h>
3081 #ifdef HAVE_LIBUTF8_H
3082 #include <libutf8.h>
3083 #endif],
3084         [$1 value],
3085         [cf_cv_$1=yes],
3086         [cf_cv_$1=unknown])])])
3087
3088 if test "$cf_cv_$1" = yes ; then
3089         AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
3090         NEED_WCHAR_H=1
3091 fi
3092
3093 ifelse([$2],,,[
3094 # if we do not find $1 in either place, use substitution to provide a fallback.
3095 if test "$cf_cv_$1" = unknown ; then
3096         $2=1
3097 fi
3098 ])
3099 ifelse($3,,,[
3100 # if we find $1 in either place, use substitution to provide a fallback.
3101 if test "$cf_cv_$1" != unknown ; then
3102         $3=1
3103 fi
3104 ])
3105 ])dnl
3106 dnl ---------------------------------------------------------------------------
3107 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
3108 dnl ------------------
3109 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3110 dnl libraries.
3111 AC_DEFUN([CF_WITH_CURSES_DIR],[
3112
3113 AC_MSG_CHECKING(for specific curses-directory)
3114 AC_ARG_WITH(curses-dir,
3115         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
3116         [cf_cv_curses_dir=$withval],
3117         [cf_cv_curses_dir=no])
3118 AC_MSG_RESULT($cf_cv_curses_dir)
3119
3120 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
3121 then
3122         CF_PATH_SYNTAX(withval)
3123         if test -d "$cf_cv_curses_dir"
3124         then
3125                 CF_ADD_INCDIR($cf_cv_curses_dir/include)
3126                 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
3127         fi
3128 fi
3129 ])dnl
3130 dnl ---------------------------------------------------------------------------
3131 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3132 dnl ----------------
3133 dnl Configure-option for dbmalloc.  The optional parameter is used to override
3134 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3135 AC_DEFUN([CF_WITH_DBMALLOC],[
3136 CF_NO_LEAKS_OPTION(dbmalloc,
3137         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3138         [USE_DBMALLOC])
3139
3140 if test "$with_dbmalloc" = yes ; then
3141         AC_CHECK_HEADER(dbmalloc.h,
3142                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3143 fi
3144 ])dnl
3145 dnl ---------------------------------------------------------------------------
3146 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3147 dnl ---------------
3148 dnl Configure-option for dmalloc.  The optional parameter is used to override
3149 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3150 AC_DEFUN([CF_WITH_DMALLOC],[
3151 CF_NO_LEAKS_OPTION(dmalloc,
3152         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
3153         [USE_DMALLOC])
3154
3155 if test "$with_dmalloc" = yes ; then
3156         AC_CHECK_HEADER(dmalloc.h,
3157                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3158 fi
3159 ])dnl
3160 dnl ---------------------------------------------------------------------------
3161 dnl CF_WITH_NCURSES_ETC version: 4 updated: 2015/04/25 20:53:11
3162 dnl -------------------
3163 dnl Use this macro for programs which use any variant of "curses", e.g.,
3164 dnl "ncurses", and "PDCurses".  Programs that can use curses and some unrelated
3165 dnl library (such as slang) should use a "--with-screen=XXX" option.
3166 dnl
3167 dnl This does not use AC_DEFUN, because that would tell autoconf to run each
3168 dnl of the macros inside this one - before this macro.
3169 define([CF_WITH_NCURSES_ETC],[
3170 CF_WITH_CURSES_DIR
3171
3172 cf_cv_screen=curses
3173
3174 AC_MSG_CHECKING(for specified curses library type)
3175 AC_ARG_WITH(screen,
3176         [  --with-screen=XXX       use specified curses-libraries],
3177         [cf_cv_screen=$withval],[
3178
3179 AC_ARG_WITH(ncursesw,
3180         [  --with-ncursesw         use wide ncurses-libraries],
3181         [cf_cv_screen=ncursesw],[
3182
3183 AC_ARG_WITH(ncurses,
3184         [  --with-ncurses          use ncurses-libraries],
3185         [cf_cv_screen=ncurses],[
3186
3187 AC_ARG_WITH(pdcurses,
3188         [  --with-pdcurses         compile/link with pdcurses X11 library],
3189         [cf_cv_screen=pdcurses],[
3190
3191 AC_ARG_WITH(curses-colr,
3192         [  --with-curses-colr      compile/link with HPUX 10.x color-curses],
3193         [cf_cv_screen=curses_colr],[
3194
3195 AC_ARG_WITH(curses-5lib,
3196         [  --with-curses-5lib      compile/link with SunOS 5lib curses],
3197         [cf_cv_screen=curses_5lib])])])])])])
3198
3199 AC_MSG_RESULT($cf_cv_screen)
3200
3201 case $cf_cv_screen in
3202 (curses|curses_*)
3203         CF_CURSES_CONFIG
3204         ;;
3205 (ncursesw*)
3206         CF_UTF8_LIB
3207         CF_NCURSES_CONFIG($cf_cv_screen)
3208         ;;
3209 (ncurses*)
3210         CF_NCURSES_CONFIG($cf_cv_screen)
3211         ;;
3212 (pdcurses)
3213         CF_PDCURSES_X11
3214         ;;
3215 (*)
3216         AC_MSG_ERROR(unexpected screen-value: $cf_cv_screen)
3217         ;;
3218 esac
3219
3220 ])dnl
3221 dnl ---------------------------------------------------------------------------
3222 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3223 dnl ----------------
3224 AC_DEFUN([CF_WITH_VALGRIND],[
3225 CF_NO_LEAKS_OPTION(valgrind,
3226         [  --with-valgrind         test: use valgrind],
3227         [USE_VALGRIND])
3228 ])dnl
3229 dnl ---------------------------------------------------------------------------
3230 dnl CF_XOPEN_CURSES version: 11 updated: 2011/01/18 18:15:30
3231 dnl ---------------
3232 dnl Test if we should define X/Open source for curses, needed on Digital Unix
3233 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
3234 dnl
3235 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
3236 dnl as getbegy().  The latter is better design, but the former is standard.
3237 AC_DEFUN([CF_XOPEN_CURSES],
3238 [
3239 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3240 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
3241 AC_TRY_LINK([
3242 #include <stdlib.h>
3243 #include <${cf_cv_ncurses_header:-curses.h}>],[
3244 #if defined(NCURSES_VERSION_PATCH)
3245 #if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
3246         make an error
3247 #endif
3248 #endif
3249         long x = winnstr(stdscr, "", 0);
3250         int x1, y1;
3251         getbegyx(stdscr, y1, x1)],
3252         [cf_cv_need_xopen_extension=no],
3253         [AC_TRY_LINK([
3254 #define _XOPEN_SOURCE_EXTENDED
3255 #include <stdlib.h>
3256 #include <${cf_cv_ncurses_header:-curses.h}>],[
3257 #ifdef NCURSES_VERSION
3258         cchar_t check;
3259         int check2 = curs_set((int)sizeof(check));
3260 #endif
3261         long x = winnstr(stdscr, "", 0);
3262         int x1, y1;
3263         getbegyx(stdscr, y1, x1)],
3264         [cf_cv_need_xopen_extension=yes],
3265         [cf_cv_need_xopen_extension=unknown])])])
3266 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
3267 ])dnl
3268 dnl ---------------------------------------------------------------------------
3269 dnl CF_XOPEN_SOURCE version: 49 updated: 2015/04/12 15:39:00
3270 dnl ---------------
3271 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3272 dnl or adapt to the vendor's definitions to get equivalent functionality,
3273 dnl without losing the common non-POSIX features.
3274 dnl
3275 dnl Parameters:
3276 dnl     $1 is the nominal value for _XOPEN_SOURCE
3277 dnl     $2 is the nominal value for _POSIX_C_SOURCE
3278 AC_DEFUN([CF_XOPEN_SOURCE],[
3279 AC_REQUIRE([AC_CANONICAL_HOST])
3280
3281 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3282 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3283 cf_xopen_source=
3284
3285 case $host_os in
3286 (aix[[4-7]]*)
3287         cf_xopen_source="-D_ALL_SOURCE"
3288         ;;
3289 (cygwin|msys)
3290         cf_XOPEN_SOURCE=600
3291         ;;
3292 (darwin[[0-8]].*)
3293         cf_xopen_source="-D_APPLE_C_SOURCE"
3294         ;;
3295 (darwin*)
3296         cf_xopen_source="-D_DARWIN_C_SOURCE"
3297         cf_XOPEN_SOURCE=
3298         ;;
3299 (freebsd*|dragonfly*)
3300         # 5.x headers associate
3301         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3302         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3303         cf_POSIX_C_SOURCE=200112L
3304         cf_XOPEN_SOURCE=600
3305         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3306         ;;
3307 (hpux11*)
3308         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3309         ;;
3310 (hpux*)
3311         cf_xopen_source="-D_HPUX_SOURCE"
3312         ;;
3313 (irix[[56]].*)
3314         cf_xopen_source="-D_SGI_SOURCE"
3315         cf_XOPEN_SOURCE=
3316         ;;
3317 (linux*|gnu*|mint*|k*bsd*-gnu)
3318         CF_GNU_SOURCE
3319         ;;
3320 (minix*)
3321         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
3322         ;;
3323 (mirbsd*)
3324         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
3325         cf_XOPEN_SOURCE=
3326         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3327         ;;
3328 (netbsd*)
3329         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3330         ;;
3331 (openbsd[[4-9]]*)
3332         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
3333         cf_xopen_source="-D_BSD_SOURCE"
3334         cf_XOPEN_SOURCE=600
3335         ;;
3336 (openbsd*)
3337         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3338         ;;
3339 (osf[[45]]*)
3340         cf_xopen_source="-D_OSF_SOURCE"
3341         ;;
3342 (nto-qnx*)
3343         cf_xopen_source="-D_QNX_SOURCE"
3344         ;;
3345 (sco*)
3346         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3347         ;;
3348 (solaris2.*)
3349         cf_xopen_source="-D__EXTENSIONS__"
3350         cf_cv_xopen_source=broken
3351         ;;
3352 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
3353         cf_XOPEN_SOURCE=
3354         cf_POSIX_C_SOURCE=
3355         ;;
3356 (*)
3357         CF_TRY_XOPEN_SOURCE
3358         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3359         ;;
3360 esac
3361
3362 if test -n "$cf_xopen_source" ; then
3363         CF_ADD_CFLAGS($cf_xopen_source,true)
3364 fi
3365
3366 dnl In anything but the default case, we may have system-specific setting
3367 dnl which is still not guaranteed to provide all of the entrypoints that
3368 dnl _XOPEN_SOURCE would yield.
3369 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
3370         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
3371         AC_TRY_COMPILE([#include <stdlib.h>],[
3372 #ifndef _XOPEN_SOURCE
3373 make an error
3374 #endif],
3375         [cf_XOPEN_SOURCE_set=yes],
3376         [cf_XOPEN_SOURCE_set=no])
3377         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
3378         if test $cf_XOPEN_SOURCE_set = yes
3379         then
3380                 AC_TRY_COMPILE([#include <stdlib.h>],[
3381 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
3382 make an error
3383 #endif],
3384                 [cf_XOPEN_SOURCE_set_ok=yes],
3385                 [cf_XOPEN_SOURCE_set_ok=no])
3386                 if test $cf_XOPEN_SOURCE_set_ok = no
3387                 then
3388                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
3389                 fi
3390         else
3391                 CF_TRY_XOPEN_SOURCE
3392         fi
3393 fi
3394 ])
3395 dnl ---------------------------------------------------------------------------
3396 dnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
3397 dnl -----------
3398 dnl Check for Xaw (Athena) libraries
3399 dnl
3400 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
3401 AC_DEFUN([CF_X_ATHENA],
3402 [
3403 cf_x_athena=${cf_x_athena:-Xaw}
3404
3405 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
3406 withval=
3407 AC_ARG_WITH(Xaw3d,
3408         [  --with-Xaw3d            link with Xaw 3d library])
3409 if test "$withval" = yes ; then
3410         cf_x_athena=Xaw3d
3411         AC_MSG_RESULT(yes)
3412 else
3413         AC_MSG_RESULT(no)
3414 fi
3415
3416 AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
3417 withval=
3418 AC_ARG_WITH(Xaw3dxft,
3419         [  --with-Xaw3dxft         link with Xaw 3d xft library])
3420 if test "$withval" = yes ; then
3421         cf_x_athena=Xaw3dxft
3422         AC_MSG_RESULT(yes)
3423 else
3424         AC_MSG_RESULT(no)
3425 fi
3426
3427 AC_MSG_CHECKING(if you want to link with neXT Athena library)
3428 withval=
3429 AC_ARG_WITH(neXtaw,
3430         [  --with-neXtaw           link with neXT Athena library])
3431 if test "$withval" = yes ; then
3432         cf_x_athena=neXtaw
3433         AC_MSG_RESULT(yes)
3434 else
3435         AC_MSG_RESULT(no)
3436 fi
3437
3438 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
3439 withval=
3440 AC_ARG_WITH(XawPlus,
3441         [  --with-XawPlus          link with Athena-Plus library])
3442 if test "$withval" = yes ; then
3443         cf_x_athena=XawPlus
3444         AC_MSG_RESULT(yes)
3445 else
3446         AC_MSG_RESULT(no)
3447 fi
3448
3449 cf_x_athena_lib=""
3450
3451 if test "$PKG_CONFIG" != none ; then
3452         cf_athena_list=
3453         test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
3454         for cf_athena_pkg in \
3455                 $cf_athena_list \
3456                 ${cf_x_athena} \
3457                 ${cf_x_athena}-devel \
3458                 lib${cf_x_athena} \
3459                 lib${cf_x_athena}-devel
3460         do
3461                 CF_TRY_PKG_CONFIG($cf_athena_pkg,[
3462                         cf_x_athena_lib="$cf_pkgconfig_libs"
3463                         CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3464                         AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3465
3466                         CF_TRIM_X_LIBS
3467
3468 AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
3469 AC_TRY_LINK([
3470 #include <X11/Xmu/CharSet.h>
3471 ],[
3472 int check = XmuCompareISOLatin1("big", "small")
3473 ],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
3474
3475                         if test "$cf_cv_xaw_compat" = no
3476                         then
3477                                 # workaround for broken ".pc" files...
3478                                 case "$cf_x_athena_lib" in
3479                                 (*-lXmu*)
3480                                         ;;
3481                                 (*)
3482                                         CF_VERBOSE(work around broken package)
3483                                         cf_save_xmu="$LIBS"
3484                                         cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
3485                                         CF_TRY_PKG_CONFIG(xmu,[
3486                                                         LIBS="$cf_save_xmu"
3487                                                         CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
3488                                                 ],[
3489                                                         CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
3490                                                 ])
3491                                         CF_TRIM_X_LIBS
3492                                         ;;
3493                                 esac
3494                         fi
3495
3496                         break])
3497         done
3498 fi
3499
3500 if test -z "$cf_x_athena_lib" ; then
3501         CF_X_EXT
3502         CF_X_TOOLKIT
3503         CF_X_ATHENA_CPPFLAGS($cf_x_athena)
3504         CF_X_ATHENA_LIBS($cf_x_athena)
3505 fi
3506 ])dnl
3507 dnl ---------------------------------------------------------------------------
3508 dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
3509 dnl --------------------
3510 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3511 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3512 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
3513 [
3514 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3515 cf_x_athena_inc=""
3516
3517 for cf_path in default \
3518         /usr/contrib/X11R6 \
3519         /usr/contrib/X11R5 \
3520         /usr/lib/X11R5 \
3521         /usr/local
3522 do
3523         if test -z "$cf_x_athena_inc" ; then
3524                 cf_save="$CPPFLAGS"
3525                 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
3526                 if test $cf_path != default ; then
3527                         CPPFLAGS="$cf_save -I$cf_path/include"
3528                         AC_MSG_CHECKING(for $cf_test in $cf_path)
3529                 else
3530                         AC_MSG_CHECKING(for $cf_test)
3531                 fi
3532                 AC_TRY_COMPILE([
3533 #include <X11/Intrinsic.h>
3534 #include <$cf_test>],[],
3535                         [cf_result=yes],
3536                         [cf_result=no])
3537                 AC_MSG_RESULT($cf_result)
3538                 if test "$cf_result" = yes ; then
3539                         cf_x_athena_inc=$cf_path
3540                         break
3541                 else
3542                         CPPFLAGS="$cf_save"
3543                 fi
3544         fi
3545 done
3546
3547 if test -z "$cf_x_athena_inc" ; then
3548         AC_MSG_WARN(
3549 [Unable to successfully find Athena header files with test program])
3550 elif test "$cf_x_athena_inc" != default ; then
3551         CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
3552 fi
3553 ])
3554 dnl ---------------------------------------------------------------------------
3555 dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
3556 dnl ----------------
3557 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3558 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3559 AC_DEFUN([CF_X_ATHENA_LIBS],
3560 [AC_REQUIRE([CF_X_TOOLKIT])
3561 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3562 cf_x_athena_lib=""
3563
3564 for cf_path in default \
3565         /usr/contrib/X11R6 \
3566         /usr/contrib/X11R5 \
3567         /usr/lib/X11R5 \
3568         /usr/local
3569 do
3570         for cf_lib in \
3571                 ${cf_x_athena_root} \
3572                 ${cf_x_athena_root}7 \
3573                 ${cf_x_athena_root}6
3574         do
3575         for cf_libs in \
3576                 "-l$cf_lib -lXmu" \
3577                 "-l$cf_lib -lXpm -lXmu" \
3578                 "-l${cf_lib}_s -lXmu_s"
3579         do
3580                 if test -z "$cf_x_athena_lib" ; then
3581                         cf_save="$LIBS"
3582                         cf_test=XawSimpleMenuAddGlobalActions
3583                         if test $cf_path != default ; then
3584                                 CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
3585                                 AC_MSG_CHECKING(for $cf_libs in $cf_path)
3586                         else
3587                                 CF_ADD_LIBS($cf_libs)
3588                                 AC_MSG_CHECKING(for $cf_test in $cf_libs)
3589                         fi
3590                         AC_TRY_LINK([
3591 #include <X11/Intrinsic.h>
3592 #include <X11/$cf_x_athena_root/SimpleMenu.h>
3593 ],[
3594 $cf_test((XtAppContext) 0)],
3595                                 [cf_result=yes],
3596                                 [cf_result=no])
3597                         AC_MSG_RESULT($cf_result)
3598                         if test "$cf_result" = yes ; then
3599                                 cf_x_athena_lib="$cf_libs"
3600                                 break
3601                         fi
3602                         LIBS="$cf_save"
3603                 fi
3604         done # cf_libs
3605                 test -n "$cf_x_athena_lib" && break
3606         done # cf_lib
3607 done
3608
3609 if test -z "$cf_x_athena_lib" ; then
3610         AC_MSG_ERROR(
3611 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
3612 fi
3613
3614 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3615 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3616 ])
3617 dnl ---------------------------------------------------------------------------
3618 dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
3619 dnl --------
3620 AC_DEFUN([CF_X_EXT],[
3621 CF_TRY_PKG_CONFIG(Xext,,[
3622         AC_CHECK_LIB(Xext,XextCreateExtension,
3623                 [CF_ADD_LIB(Xext)])])
3624 ])dnl
3625 dnl ---------------------------------------------------------------------------
3626 dnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
3627 dnl ------------
3628 dnl Check for X Toolkit libraries
3629 AC_DEFUN([CF_X_TOOLKIT],
3630 [
3631 AC_REQUIRE([AC_PATH_XTRA])
3632 AC_REQUIRE([CF_CHECK_CACHE])
3633
3634 # OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
3635 # in some cases has installed dummy files in the former, other cases replaced
3636 # it with a link to the new location).  This complicates the configure script.
3637 # Check for that pitfall, and recover using pkg-config
3638 #
3639 # If none of these are set, the configuration is almost certainly broken.
3640 if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
3641 then
3642         CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
3643         CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
3644         CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
3645         CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
3646 fi
3647
3648 cf_have_X_LIBS=no
3649
3650 CF_TRY_PKG_CONFIG(xt,[
3651
3652         case "x$LIBS" in
3653         (*-lX11*)
3654                 ;;
3655         (*)
3656 # we have an "xt" package, but it may omit Xt's dependency on X11
3657 AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
3658 AC_TRY_LINK([
3659 #include <X11/Xlib.h>
3660 ],[
3661         int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
3662         int rc2 = XClearWindow((Display*) 0, (Window) 0);
3663         int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
3664         int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
3665 ],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
3666                 if test "$cf_cv_xt_x11_compat" = no
3667                 then
3668                         CF_VERBOSE(work around broken X11 dependency)
3669                         # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
3670                         CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
3671                 fi
3672                 ;;
3673         esac
3674
3675 AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
3676 AC_TRY_LINK([
3677 #include <X11/Shell.h>
3678 ],[int num = IceConnectionNumber(0)
3679 ],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
3680
3681         if test "$cf_cv_xt_ice_compat" = no
3682         then
3683                 # workaround for broken ".pc" files used for X Toolkit.
3684                 case "x$X_PRE_LIBS" in
3685                 (*-lICE*)
3686                         case "x$LIBS" in
3687                         (*-lICE*)
3688                                 ;;
3689                         (*)
3690                                 CF_VERBOSE(work around broken ICE dependency)
3691                                 CF_TRY_PKG_CONFIG(ice,
3692                                         [CF_TRY_PKG_CONFIG(sm)],
3693                                         [CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
3694                                 ;;
3695                         esac
3696                         ;;
3697                 esac
3698         fi
3699
3700         cf_have_X_LIBS=yes
3701 ],[
3702
3703         LDFLAGS="$X_LIBS $LDFLAGS"
3704         CF_CHECK_CFLAGS($X_CFLAGS)
3705
3706         AC_CHECK_FUNC(XOpenDisplay,,[
3707         AC_CHECK_LIB(X11,XOpenDisplay,
3708                 [CF_ADD_LIB(X11)],,
3709                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3710
3711         AC_CHECK_FUNC(XtAppInitialize,,[
3712         AC_CHECK_LIB(Xt, XtAppInitialize,
3713                 [AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
3714                  cf_have_X_LIBS=Xt
3715                  LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
3716                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3717 ])
3718
3719 if test $cf_have_X_LIBS = no ; then
3720         AC_MSG_WARN(
3721 [Unable to successfully link X Toolkit library (-lXt) with
3722 test program.  You will have to check and add the proper libraries by hand
3723 to makefile.])
3724 fi
3725 ])dnl
3726 dnl ---------------------------------------------------------------------------
3727 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
3728 dnl ---------------
3729 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
3730 dnl are both available.
3731 define([CF__CURSES_HEAD],[
3732 #ifdef HAVE_XCURSES
3733 #include <xcurses.h>
3734 char * XCursesProgramName = "test";
3735 #else
3736 #include <${cf_cv_ncurses_header:-curses.h}>
3737 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
3738 #include <ncursesw/term.h>
3739 #elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
3740 #include <ncurses/term.h>
3741 #elif defined(HAVE_TERM_H)
3742 #include <term.h>
3743 #endif
3744 #endif
3745 ])