]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/aclocal.m4
ncurses 5.8 - patch 20110305
[ncurses.git] / test / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2003-2010,2011 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.49 2011/01/15 23:47:10 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_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
44 dnl -------------
45 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
46 dnl The second parameter if given makes this macro verbose.
47 dnl
48 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
49 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
50 dnl confused by the quotes (which require backslashes to keep them usable).
51 AC_DEFUN([CF_ADD_CFLAGS],
52 [
53 cf_fix_cppflags=no
54 cf_new_cflags=
55 cf_new_cppflags=
56 cf_new_extra_cppflags=
57
58 for cf_add_cflags in $1
59 do
60 case $cf_fix_cppflags in
61 no)
62         case $cf_add_cflags in #(vi
63         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
64                 case $cf_add_cflags in
65                 -D*)
66                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
67
68                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
69                                 && test -z "${cf_tst_cflags}" \
70                                 && cf_fix_cppflags=yes
71
72                         if test $cf_fix_cppflags = yes ; then
73                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
74                                 continue
75                         elif test "${cf_tst_cflags}" = "\"'" ; then
76                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
77                                 continue
78                         fi
79                         ;;
80                 esac
81                 case "$CPPFLAGS" in
82                 *$cf_add_cflags) #(vi
83                         ;;
84                 *) #(vi
85                         case $cf_add_cflags in #(vi
86                         -D*)
87                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
88                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
89                                 ;;
90                         esac
91                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
92                         ;;
93                 esac
94                 ;;
95         *)
96                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
97                 ;;
98         esac
99         ;;
100 yes)
101         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
102
103         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
104
105         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
106                 && test -z "${cf_tst_cflags}" \
107                 && cf_fix_cppflags=no
108         ;;
109 esac
110 done
111
112 if test -n "$cf_new_cflags" ; then
113         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
114         CFLAGS="$CFLAGS $cf_new_cflags"
115 fi
116
117 if test -n "$cf_new_cppflags" ; then
118         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
119         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
120 fi
121
122 if test -n "$cf_new_extra_cppflags" ; then
123         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
124         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
125 fi
126
127 AC_SUBST(EXTRA_CPPFLAGS)
128
129 ])dnl
130 dnl ---------------------------------------------------------------------------
131 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
132 dnl -------------
133 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
134 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
135 dnl but old versions (and some misinstalled ones) need that.  To make things
136 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
137 dnl the include-path).
138 AC_DEFUN([CF_ADD_INCDIR],
139 [
140 if test -n "$1" ; then
141   for cf_add_incdir in $1
142   do
143         while test $cf_add_incdir != /usr/include
144         do
145           if test -d $cf_add_incdir
146           then
147                 cf_have_incdir=no
148                 if test -n "$CFLAGS$CPPFLAGS" ; then
149                   # a loop is needed to ensure we can add subdirs of existing dirs
150                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
151                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
152                           cf_have_incdir=yes; break
153                         fi
154                   done
155                 fi
156
157                 if test "$cf_have_incdir" = no ; then
158                   if test "$cf_add_incdir" = /usr/local/include ; then
159                         if test "$GCC" = yes
160                         then
161                           cf_save_CPPFLAGS=$CPPFLAGS
162                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
163                           AC_TRY_COMPILE([#include <stdio.h>],
164                                   [printf("Hello")],
165                                   [],
166                                   [cf_have_incdir=yes])
167                           CPPFLAGS=$cf_save_CPPFLAGS
168                         fi
169                   fi
170                 fi
171
172                 if test "$cf_have_incdir" = no ; then
173                   CF_VERBOSE(adding $cf_add_incdir to include-path)
174                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
175
176                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
177                   test "$cf_top_incdir" = "$cf_add_incdir" && break
178                   cf_add_incdir="$cf_top_incdir"
179                 else
180                   break
181                 fi
182           fi
183         done
184   done
185 fi
186 ])dnl
187 dnl ---------------------------------------------------------------------------
188 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
189 dnl ----------
190 dnl Add a library, used to enforce consistency.
191 dnl
192 dnl $1 = library to add, without the "-l"
193 dnl $2 = variable to update (default $LIBS)
194 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
195 dnl ---------------------------------------------------------------------------
196 dnl CF_ADD_LIBDIR version: 9 updated: 2010/05/26 16:44:57
197 dnl -------------
198 dnl     Adds to the library-path
199 dnl
200 dnl     Some machines have trouble with multiple -L options.
201 dnl
202 dnl $1 is the (list of) directory(s) to add
203 dnl $2 is the optional name of the variable to update (default LDFLAGS)
204 dnl
205 AC_DEFUN([CF_ADD_LIBDIR],
206 [
207 if test -n "$1" ; then
208   for cf_add_libdir in $1
209   do
210     if test $cf_add_libdir = /usr/lib ; then
211       :
212     elif test -d $cf_add_libdir
213     then
214       cf_have_libdir=no
215       if test -n "$LDFLAGS$LIBS" ; then
216         # a loop is needed to ensure we can add subdirs of existing dirs
217         for cf_test_libdir in $LDFLAGS $LIBS ; do
218           if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
219             cf_have_libdir=yes; break
220           fi
221         done
222       fi
223       if test "$cf_have_libdir" = no ; then
224         CF_VERBOSE(adding $cf_add_libdir to library-path)
225         ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
226       fi
227     fi
228   done
229 fi
230 ])dnl
231 dnl ---------------------------------------------------------------------------
232 dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
233 dnl -----------
234 dnl Add one or more libraries, used to enforce consistency.
235 dnl
236 dnl $1 = libraries to add, with the "-l", etc.
237 dnl $2 = variable to update (default $LIBS)
238 AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
239 dnl ---------------------------------------------------------------------------
240 dnl CF_ADD_LIB_AFTER version: 2 updated: 2010/11/08 20:33:46
241 dnl ----------------
242 dnl Add a given library after another, e.g., following the one it satisfies a
243 dnl dependency for.
244 dnl
245 dnl $1 = the first library
246 dnl $2 = its dependency
247 AC_DEFUN([CF_ADD_LIB_AFTER],[
248 CF_VERBOSE(...before $LIBS)
249 LIBS=`echo "$LIBS" | sed -e "s/[[       ]][[    ]]*/ /g" -e "s,$1 ,$1 $2 ," -e 's/  / /g'`
250 CF_VERBOSE(...after  $LIBS)
251 ])dnl
252 dnl ---------------------------------------------------------------------------
253 dnl CF_ADD_SUBDIR_PATH version: 3 updated: 2010/07/03 20:58:12
254 dnl ------------------
255 dnl Append to a search-list for a nonstandard header/lib-file
256 dnl     $1 = the variable to return as result
257 dnl     $2 = the package name
258 dnl     $3 = the subdirectory, e.g., bin, include or lib
259 dnl $4 = the directory under which we will test for subdirectories
260 dnl $5 = a directory that we do not want $4 to match
261 AC_DEFUN([CF_ADD_SUBDIR_PATH],
262 [
263 test "$4" != "$5" && \
264 test -d "$4" && \
265 ifelse([$5],NONE,,[(test $5 = NONE || test "$4" != "$5") &&]) {
266         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
267         test -d $4/$3 &&          $1="[$]$1 $4/$3"
268         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
269         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
270         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
271         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
272 }
273 ])dnl
274 dnl ---------------------------------------------------------------------------
275 dnl CF_ANSI_CC_CHECK version: 10 updated: 2010/10/23 15:52:32
276 dnl ----------------
277 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
278 dnl in the sharutils 4.2 distribution.
279 AC_DEFUN([CF_ANSI_CC_CHECK],
280 [
281 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
282 cf_cv_ansi_cc=no
283 cf_save_CFLAGS="$CFLAGS"
284 cf_save_CPPFLAGS="$CPPFLAGS"
285 # Don't try gcc -ansi; that turns off useful extensions and
286 # breaks some systems' header files.
287 # AIX                   -qlanglvl=ansi
288 # Ultrix and OSF/1      -std1
289 # HP-UX                 -Aa -D_HPUX_SOURCE
290 # SVR4                  -Xc
291 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
292 for cf_arg in "-DCC_HAS_PROTOS" \
293         "" \
294         -qlanglvl=ansi \
295         -std1 \
296         -Ae \
297         "-Aa -D_HPUX_SOURCE" \
298         -Xc
299 do
300         CF_ADD_CFLAGS($cf_arg)
301         AC_TRY_COMPILE(
302 [
303 #ifndef CC_HAS_PROTOS
304 #if !defined(__STDC__) || (__STDC__ != 1)
305 choke me
306 #endif
307 #endif
308 ],[
309         int test (int i, double x);
310         struct s1 {int (*f) (int a);};
311         struct s2 {int (*f) (double a);};],
312         [cf_cv_ansi_cc="$cf_arg"; break])
313 done
314 CFLAGS="$cf_save_CFLAGS"
315 CPPFLAGS="$cf_save_CPPFLAGS"
316 ])
317
318 if test "$cf_cv_ansi_cc" != "no"; then
319 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
320         CF_ADD_CFLAGS($cf_cv_ansi_cc)
321 else
322         AC_DEFINE(CC_HAS_PROTOS)
323 fi
324 fi
325 ])dnl
326 dnl ---------------------------------------------------------------------------
327 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
328 dnl ---------------
329 dnl For programs that must use an ANSI compiler, obtain compiler options that
330 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
331 dnl macros, since tools such as unproto can fake prototypes, but only part of
332 dnl the preprocessor.
333 AC_DEFUN([CF_ANSI_CC_REQD],
334 [AC_REQUIRE([CF_ANSI_CC_CHECK])
335 if test "$cf_cv_ansi_cc" = "no"; then
336         AC_MSG_ERROR(
337 [Your compiler does not appear to recognize prototypes.
338 You have the following choices:
339         a. adjust your compiler options
340         b. get an up-to-date compiler
341         c. use a wrapper such as unproto])
342 fi
343 ])dnl
344 dnl ---------------------------------------------------------------------------
345 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
346 dnl --------------
347 dnl Allow user to disable a normally-on option.
348 AC_DEFUN([CF_ARG_DISABLE],
349 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
350 dnl ---------------------------------------------------------------------------
351 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
352 dnl -------------
353 dnl Allow user to enable a normally-off option.
354 AC_DEFUN([CF_ARG_ENABLE],
355 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
356 dnl ---------------------------------------------------------------------------
357 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
358 dnl -------------
359 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
360 dnl values.
361 dnl
362 dnl Parameters:
363 dnl $1 = option name
364 dnl $2 = help-string
365 dnl $3 = action to perform if option is not default
366 dnl $4 = action if perform if option is default
367 dnl $5 = default option value (either 'yes' or 'no')
368 AC_DEFUN([CF_ARG_OPTION],
369 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
370   if test "$enableval" != "$5" ; then
371 ifelse([$3],,[    :]dnl
372 ,[    $3]) ifelse([$4],,,[
373   else
374     $4])
375   fi],[enableval=$5 ifelse([$4],,,[
376   $4
377 ])dnl
378   ])])dnl
379 dnl ---------------------------------------------------------------------------
380 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
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")
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: 2 updated: 2001/12/30 19:09:58
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 "$cf_check_cflags" != "$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 "$cf_check_cppflags" != "$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_CURSES_ACS_MAP version: 6 updated: 2010/10/23 15:54:49
438 dnl -----------------
439 dnl Check for likely values of acs_map[]:
440 AC_DEFUN([CF_CURSES_ACS_MAP],
441 [
442 AC_REQUIRE([CF_NCURSES_WRAP_PREFIX])dnl
443 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
444 cf_cv_curses_acs_map=unknown
445 for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
446 do
447 AC_TRY_LINK([
448 #include <${cf_cv_ncurses_header:-curses.h}>
449 ],[
450 $name['k'] = ACS_PLUS
451 ],[cf_cv_curses_acs_map=$name; break])
452 done
453 ])
454
455 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
456 ])
457 dnl ---------------------------------------------------------------------------
458 dnl CF_CURSES_CHECK_DATA version: 4 updated: 2011/01/15 16:39:24
459 dnl --------------------
460 dnl Check if curses.h defines the given data/variable.
461 dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
462 AC_DEFUN([CF_CURSES_CHECK_DATA],
463 [
464 AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header:-curses.h})
465
466 AC_TRY_COMPILE(CF__CURSES_HEAD,[
467 void *foo = &($1)
468 ],cf_result=yes,cf_result=no)
469 AC_MSG_RESULT($cf_result)
470
471 if test $cf_result = yes ; then
472         CF_UPPER(cf_result,have_curses_data_$1)
473         AC_DEFINE_UNQUOTED($cf_result)
474 else
475         AC_MSG_CHECKING(for data $1 in library)
476         # BSD linkers insist on making weak linkage, but resolve at runtime.
477         AC_TRY_RUN(CF__CURSES_HEAD
478 [
479 extern char $1;
480 int main(void)
481 {
482         void *foo = &($1);
483         ${cf_cv_main_return:-return}(foo == 0);
484 }],[cf_result=yes],[cf_result=no],[
485         # cross-compiling
486         AC_TRY_LINK(CF__CURSES_HEAD
487 [extern char $1;],[
488         do {
489                 void *foo = &($1);
490                 ${cf_cv_main_return:-return}(foo == 0);
491         } while (0)
492 ],[cf_result=yes],[cf_result=no])
493 ])
494         AC_MSG_RESULT($cf_result)
495         if test $cf_result = yes ; then
496                 CF_UPPER(cf_result,decl_curses_data_$1)
497                 AC_DEFINE_UNQUOTED($cf_result)
498         fi
499 fi
500 ])dnl
501 dnl ---------------------------------------------------------------------------
502 dnl CF_CURSES_CHECK_TYPE version: 3 updated: 2010/10/23 15:54:49
503 dnl --------------------
504 dnl Check if curses.h defines the given type
505 AC_DEFUN([CF_CURSES_CHECK_TYPE],
506 [
507 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header:-curses.h})
508 AC_TRY_COMPILE([
509 #ifndef _XOPEN_SOURCE_EXTENDED
510 #define _XOPEN_SOURCE_EXTENDED
511 #endif
512 #include <${cf_cv_ncurses_header:-curses.h}>],[
513 $1 foo
514 ],cf_result=yes,cf_result=no)
515 AC_MSG_RESULT($cf_result)
516 if test $cf_result = yes ; then
517         CF_UPPER(cf_result,have_type_$1)
518         AC_DEFINE_UNQUOTED($cf_result)
519 else
520         AC_DEFINE_UNQUOTED($1,$2)
521 fi
522 ])dnl
523 dnl ---------------------------------------------------------------------------
524 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
525 dnl ----------------
526 dnl Tie together the configure-script macros for curses.  It may be ncurses,
527 dnl but unless asked, we do not make a special search for ncurses.  However,
528 dnl still check for the ncurses version number, for use in other macros.
529 AC_DEFUN([CF_CURSES_CONFIG],
530 [
531 CF_CURSES_CPPFLAGS
532 CF_NCURSES_VERSION
533 CF_CURSES_LIBS
534 ])dnl
535 dnl ---------------------------------------------------------------------------
536 dnl CF_CURSES_CPPFLAGS version: 10 updated: 2009/01/06 19:34:11
537 dnl ------------------
538 dnl Look for the curses headers.
539 AC_DEFUN([CF_CURSES_CPPFLAGS],[
540
541 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
542 cf_cv_curses_incdir=no
543 case $host_os in #(vi
544 hpux10.*) #(vi
545         test -d /usr/include/curses_colr && \
546         cf_cv_curses_incdir="-I/usr/include/curses_colr"
547         ;;
548 sunos3*|sunos4*)
549         test -d /usr/5lib && \
550         test -d /usr/5include && \
551         cf_cv_curses_incdir="-I/usr/5include"
552         ;;
553 esac
554 ])
555 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
556
557 CF_CURSES_HEADER
558 CF_TERM_HEADER
559 ])dnl
560 dnl ---------------------------------------------------------------------------
561 dnl CF_CURSES_FUNCS version: 15 updated: 2010/10/23 15:52:32
562 dnl ---------------
563 dnl Curses-functions are a little complicated, since a lot of them are macros.
564 AC_DEFUN([CF_CURSES_FUNCS],
565 [
566 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
567 AC_REQUIRE([CF_XOPEN_CURSES])
568 AC_REQUIRE([CF_CURSES_TERM_H])
569 for cf_func in $1
570 do
571         CF_UPPER(cf_tr_func,$cf_func)
572         AC_MSG_CHECKING(for ${cf_func})
573         CF_MSG_LOG(${cf_func})
574         AC_CACHE_VAL(cf_cv_func_$cf_func,[
575                 eval cf_result='$ac_cv_func_'$cf_func
576                 if test ".$cf_result" != ".no"; then
577                         AC_TRY_LINK(CF__CURSES_HEAD,
578                         [
579 #ifndef ${cf_func}
580 long foo = (long)(&${cf_func});
581 ${cf_cv_main_return:-return}(foo == 0);
582 #endif
583                         ],
584                         [cf_result=yes],
585                         [cf_result=no])
586                 fi
587                 eval 'cf_cv_func_'$cf_func'=$cf_result'
588         ])
589         # use the computed/retrieved cache-value:
590         eval 'cf_result=$cf_cv_func_'$cf_func
591         AC_MSG_RESULT($cf_result)
592         if test $cf_result != no; then
593                 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
594         fi
595 done
596 ])dnl
597 dnl ---------------------------------------------------------------------------
598 dnl CF_CURSES_HEADER version: 2 updated: 2010/04/28 06:02:16
599 dnl ----------------
600 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
601 dnl variations of ncurses' installs.
602 dnl
603 dnl $1 = ncurses when looking for ncurses, or is empty
604 AC_DEFUN([CF_CURSES_HEADER],[
605 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
606 cf_cv_ncurses_header=none
607 for cf_header in ifelse($1,,,[ \
608     $1/curses.h \
609         $1/ncurses.h]) \
610         curses.h \
611         ncurses.h ifelse($1,,[ncurses/curses.h ncurses/ncurses.h])
612 do
613 AC_TRY_COMPILE([#include <${cf_header}>],
614         [initscr(); tgoto("?", 0,0)],
615         [cf_cv_ncurses_header=$cf_header; break],[])
616 done
617 ])
618
619 if test "$cf_cv_ncurses_header" = none ; then
620         AC_MSG_ERROR(No curses header-files found)
621 fi
622
623 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
624 AC_CHECK_HEADERS($cf_cv_ncurses_header)
625 ])dnl
626 dnl ---------------------------------------------------------------------------
627 dnl CF_CURSES_LIBS version: 31 updated: 2010/10/23 15:54:49
628 dnl --------------
629 dnl Look for the curses libraries.  Older curses implementations may require
630 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
631 AC_DEFUN([CF_CURSES_LIBS],[
632
633 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
634 AC_MSG_CHECKING(if we have identified curses libraries)
635 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
636     [initscr(); tgoto("?", 0,0)],
637     cf_result=yes,
638     cf_result=no)
639 AC_MSG_RESULT($cf_result)
640
641 if test "$cf_result" = no ; then
642 case $host_os in #(vi
643 freebsd*) #(vi
644     AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
645     ;;
646 hpux10.*) #(vi
647     AC_CHECK_LIB(cur_colr,initscr,[
648         CF_ADD_LIBS(-lcur_colr)
649         ac_cv_func_initscr=yes
650         ],[
651     AC_CHECK_LIB(Hcurses,initscr,[
652         # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
653         CF_ADD_LIBS(-lHcurses)
654         CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
655         ac_cv_func_initscr=yes
656         ])])
657     ;;
658 linux*) # Suse Linux does not follow /usr/lib convention
659     CF_ADD_LIBDIR(/lib)
660     ;;
661 sunos3*|sunos4*)
662     if test -d /usr/5lib ; then
663       CF_ADD_LIBDIR(/usr/5lib)
664       CF_ADD_LIBS(-lcurses -ltermcap)
665     fi
666     ac_cv_func_initscr=yes
667     ;;
668 esac
669
670 if test ".$ac_cv_func_initscr" != .yes ; then
671     cf_save_LIBS="$LIBS"
672     cf_term_lib=""
673     cf_curs_lib=""
674
675     if test ".${cf_cv_ncurses_version:-no}" != .no
676     then
677         cf_check_list="ncurses curses cursesX"
678     else
679         cf_check_list="cursesX curses ncurses"
680     fi
681
682     # Check for library containing tgoto.  Do this before curses library
683     # because it may be needed to link the test-case for initscr.
684     AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
685         for cf_term_lib in $cf_check_list termcap termlib unknown
686         do
687             AC_CHECK_LIB($cf_term_lib,tgoto,[break])
688         done
689     ])
690
691     # Check for library containing initscr
692     test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
693         for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
694     do
695         AC_CHECK_LIB($cf_curs_lib,initscr,[break])
696     done
697     test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
698
699     LIBS="-l$cf_curs_lib $cf_save_LIBS"
700     if test "$cf_term_lib" = unknown ; then
701         AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
702         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
703             [initscr()],
704             [cf_result=yes],
705             [cf_result=no])
706         AC_MSG_RESULT($cf_result)
707         test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
708     elif test "$cf_curs_lib" = "$cf_term_lib" ; then
709         :
710     elif test "$cf_term_lib" != predefined ; then
711         AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
712         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
713             [initscr(); tgoto((char *)0, 0, 0);],
714             [cf_result=no],
715             [
716             LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
717             AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
718                 [initscr()],
719                 [cf_result=yes],
720                 [cf_result=error])
721             ])
722         AC_MSG_RESULT($cf_result)
723     fi
724 fi
725 fi
726
727 ])dnl
728 dnl ---------------------------------------------------------------------------
729 dnl CF_CURSES_TERM_H version: 8 updated: 2010/10/23 15:54:49
730 dnl ----------------
731 dnl SVr4 curses should have term.h as well (where it puts the definitions of
732 dnl the low-level interface).  This may not be true in old/broken implementations,
733 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
734 dnl running with Solaris 2.5.1).
735 AC_DEFUN([CF_CURSES_TERM_H],
736 [
737 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
738
739 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
740
741 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
742 # for <term.h> if we do not find the variant.
743 for cf_header in \
744         `echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%/.*%/%'`term.h \
745         term.h
746 do
747         AC_TRY_COMPILE([
748 #include <${cf_cv_ncurses_header:-curses.h}>
749 #include <${cf_header}>],
750         [WINDOW *x],
751         [cf_cv_term_header=$cf_header
752          break],
753         [cf_cv_term_header=no])
754 done
755
756 case $cf_cv_term_header in #(vi
757 no)
758         # If curses is ncurses, some packagers still mess it up by trying to make
759         # us use GNU termcap.  This handles the most common case.
760         for cf_header in ncurses/term.h ncursesw/term.h
761         do
762                 AC_TRY_COMPILE([
763 #include <${cf_cv_ncurses_header:-curses.h}>
764 #ifdef NCURSES_VERSION
765 #include <${cf_header}>
766 #else
767 make an error
768 #endif],
769                         [WINDOW *x],
770                         [cf_cv_term_header=$cf_header
771                          break],
772                         [cf_cv_term_header=no])
773         done
774         ;;
775 esac
776 ])
777
778 case $cf_cv_term_header in #(vi
779 term.h) #(vi
780         AC_DEFINE(HAVE_TERM_H)
781         ;;
782 ncurses/term.h) #(vi
783         AC_DEFINE(HAVE_NCURSES_TERM_H)
784         ;;
785 ncursesw/term.h)
786         AC_DEFINE(HAVE_NCURSESW_TERM_H)
787         ;;
788 esac
789 ])dnl
790 dnl ---------------------------------------------------------------------------
791 dnl CF_CURSES_WACS_MAP version: 5 updated: 2011/01/15 11:28:59
792 dnl ------------------
793 dnl Check for likely values of wacs_map[].
794 AC_DEFUN([CF_CURSES_WACS_MAP],
795 [
796 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
797         cf_cv_curses_wacs_map=unknown
798         for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
799         do
800         AC_TRY_LINK([
801 #ifndef _XOPEN_SOURCE_EXTENDED
802 #define _XOPEN_SOURCE_EXTENDED
803 #endif
804 #include <${cf_cv_ncurses_header:-curses.h}>],
805         [void *foo = &($name['k'])],
806         [cf_cv_curses_wacs_map=$name
807          break])
808         done])
809
810 test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map)
811 ])dnl
812 dnl ---------------------------------------------------------------------------
813 dnl CF_CURSES_WACS_SYMBOLS version: 1 updated: 2011/01/15 11:28:59
814 dnl ----------------------
815 dnl Do a check to see if the WACS_xxx constants are defined compatibly with
816 dnl X/Open Curses.  In particular, NetBSD's implementation of the WACS_xxx
817 dnl constants is broken since those constants do not point to cchar_t's.
818 AC_DEFUN([CF_CURSES_WACS_SYMBOLS],
819 [
820 AC_REQUIRE([CF_CURSES_WACS_MAP])
821
822 AC_CACHE_CHECK(for wide alternate character constants, cf_cv_curses_wacs_symbols,[
823 cf_cv_curses_wacs_symbols=no
824 if test "$cf_cv_curses_wacs_map" != unknown
825 then
826         AC_TRY_LINK([
827 #ifndef _XOPEN_SOURCE_EXTENDED
828 #define _XOPEN_SOURCE_EXTENDED
829 #endif
830 #include <${cf_cv_ncurses_header:-curses.h}>],
831         [cchar_t *foo = WACS_PLUS;
832          $cf_cv_curses_wacs_map['k'] = *WACS_PLUS],
833         [cf_cv_curses_wacs_symbols=yes])
834 else
835         AC_TRY_LINK([
836 #ifndef _XOPEN_SOURCE_EXTENDED
837 #define _XOPEN_SOURCE_EXTENDED
838 #endif
839 #include <${cf_cv_ncurses_header:-curses.h}>],
840         [cchar_t *foo = WACS_PLUS],
841         [cf_cv_curses_wacs_symbols=yes])
842 fi
843 ])
844
845 test "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS)
846 ])dnl
847 dnl ---------------------------------------------------------------------------
848 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
849 dnl ----------
850 dnl "dirname" is not portable, so we fake it with a shell script.
851 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
852 dnl ---------------------------------------------------------------------------
853 dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
854 dnl ---------------
855 dnl You can always use "make -n" to see the actual options, but it's hard to
856 dnl pick out/analyze warning messages when the compile-line is long.
857 dnl
858 dnl Sets:
859 dnl     ECHO_LT - symbol to control if libtool is verbose
860 dnl     ECHO_LD - symbol to prefix "cc -o" lines
861 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
862 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
863 dnl     ECHO_CC - symbol to put before any "cc" line
864 dnl
865 AC_DEFUN([CF_DISABLE_ECHO],[
866 AC_MSG_CHECKING(if you want to see long compiling messages)
867 CF_ARG_DISABLE(echo,
868         [  --disable-echo          display "compiling" commands],
869         [
870     ECHO_LT='--silent'
871     ECHO_LD='@echo linking [$]@;'
872     RULE_CC='@echo compiling [$]<'
873     SHOW_CC='@echo compiling [$]@'
874     ECHO_CC='@'
875 ],[
876     ECHO_LT=''
877     ECHO_LD=''
878     RULE_CC=''
879     SHOW_CC=''
880     ECHO_CC=''
881 ])
882 AC_MSG_RESULT($enableval)
883 AC_SUBST(ECHO_LT)
884 AC_SUBST(ECHO_LD)
885 AC_SUBST(RULE_CC)
886 AC_SUBST(SHOW_CC)
887 AC_SUBST(ECHO_CC)
888 ])dnl
889 dnl ---------------------------------------------------------------------------
890 dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
891 dnl ----------------
892 dnl Combine no-leak checks with the libraries or tools that are used for the
893 dnl checks.
894 AC_DEFUN([CF_DISABLE_LEAKS],[
895
896 AC_REQUIRE([CF_WITH_DMALLOC])
897 AC_REQUIRE([CF_WITH_DBMALLOC])
898 AC_REQUIRE([CF_WITH_VALGRIND])
899
900 AC_MSG_CHECKING(if you want to perform memory-leak testing)
901 AC_ARG_ENABLE(leaks,
902         [  --disable-leaks         test: free permanent memory, analyze leaks],
903         [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
904         : ${with_no_leaks:=no})
905 AC_MSG_RESULT($with_no_leaks)
906
907 if test "$with_no_leaks" = yes ; then
908         AC_DEFINE(NO_LEAKS)
909         AC_DEFINE(YY_NO_LEAKS)
910 fi
911 ])dnl
912 dnl ---------------------------------------------------------------------------
913 dnl CF_ENABLE_WARNINGS version: 4 updated: 2009/07/26 17:53:03
914 dnl ------------------
915 dnl Configure-option to enable gcc warnings
916 AC_DEFUN([CF_ENABLE_WARNINGS],[
917 if ( test "$GCC" = yes || test "$GXX" = yes )
918 then
919 AC_MSG_CHECKING(if you want to turn on gcc warnings)
920 CF_ARG_ENABLE(warnings,
921         [  --enable-warnings       test: turn on gcc compiler warnings],
922         [with_warnings=yes],
923         [with_warnings=no])
924 AC_MSG_RESULT($with_warnings)
925 if test "$with_warnings" = "yes"
926 then
927         CF_GCC_ATTRIBUTES
928         CF_GCC_WARNINGS
929 fi
930 fi
931 ])dnl
932 dnl ---------------------------------------------------------------------------
933 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
934 dnl ---------------
935 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
936 dnl prefer a standard location, and use -L options only if we do not find the
937 dnl library in the standard library location(s).
938 dnl     $1 = library name
939 dnl     $2 = library class, usually the same as library name
940 dnl     $3 = includes
941 dnl     $4 = code fragment to compile/link
942 dnl     $5 = corresponding function-name
943 dnl     $6 = flag, nonnull if failure should not cause an error-exit
944 dnl
945 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
946 dnl to use a -L option.
947 AC_DEFUN([CF_FIND_LIBRARY],
948 [
949         eval 'cf_cv_have_lib_'$1'=no'
950         cf_libdir=""
951         AC_CHECK_FUNC($5,
952                 eval 'cf_cv_have_lib_'$1'=yes',[
953                 cf_save_LIBS="$LIBS"
954                 AC_MSG_CHECKING(for $5 in -l$1)
955                 LIBS="-l$1 $LIBS"
956                 AC_TRY_LINK([$3],[$4],
957                         [AC_MSG_RESULT(yes)
958                          eval 'cf_cv_have_lib_'$1'=yes'
959                         ],
960                         [AC_MSG_RESULT(no)
961                         CF_LIBRARY_PATH(cf_search,$2)
962                         for cf_libdir in $cf_search
963                         do
964                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
965                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
966                                 AC_TRY_LINK([$3],[$4],
967                                         [AC_MSG_RESULT(yes)
968                                          eval 'cf_cv_have_lib_'$1'=yes'
969                                          break],
970                                         [AC_MSG_RESULT(no)
971                                          LIBS="$cf_save_LIBS"])
972                         done
973                         ])
974                 ])
975 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
976 ifelse($6,,[
977 if test $cf_found_library = no ; then
978         AC_MSG_ERROR(Cannot link $1 library)
979 fi
980 ])
981 ])dnl
982 dnl ---------------------------------------------------------------------------
983 dnl CF_FIND_LINKAGE version: 19 updated: 2010/05/29 16:31:02
984 dnl ---------------
985 dnl Find a library (specifically the linkage used in the code fragment),
986 dnl searching for it if it is not already in the library path.
987 dnl See also CF_ADD_SEARCHPATH.
988 dnl
989 dnl Parameters (4-on are optional):
990 dnl     $1 = headers for library entrypoint
991 dnl     $2 = code fragment for library entrypoint
992 dnl     $3 = the library name without the "-l" option or ".so" suffix.
993 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
994 dnl     $5 = action to perform if not successful
995 dnl     $6 = module name, if not the same as the library name
996 dnl     $7 = extra libraries
997 dnl
998 dnl Sets these variables:
999 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1000 dnl     $cf_cv_header_path_$3 - include-directory if needed
1001 dnl     $cf_cv_library_path_$3 - library-directory if needed
1002 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1003 AC_DEFUN([CF_FIND_LINKAGE],[
1004
1005 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1006 # will be set on completion of the AC_TRY_LINK below.
1007 cf_cv_header_path_$3=
1008 cf_cv_library_path_$3=
1009
1010 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1011
1012 cf_save_LIBS="$LIBS"
1013
1014 AC_TRY_LINK([$1],[$2],[
1015         cf_cv_find_linkage_$3=yes
1016         cf_cv_header_path_$3=/usr/include
1017         cf_cv_library_path_$3=/usr/lib
1018 ],[
1019
1020 LIBS="-l$3 $7 $cf_save_LIBS"
1021
1022 AC_TRY_LINK([$1],[$2],[
1023         cf_cv_find_linkage_$3=yes
1024         cf_cv_header_path_$3=/usr/include
1025         cf_cv_library_path_$3=/usr/lib
1026         cf_cv_library_file_$3="-l$3"
1027 ],[
1028         cf_cv_find_linkage_$3=no
1029         LIBS="$cf_save_LIBS"
1030
1031     CF_VERBOSE(find linkage for $3 library)
1032     CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1033
1034     cf_save_CPPFLAGS="$CPPFLAGS"
1035     cf_test_CPPFLAGS="$CPPFLAGS"
1036
1037     CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1038     for cf_cv_header_path_$3 in $cf_search
1039     do
1040       if test -d $cf_cv_header_path_$3 ; then
1041         CF_VERBOSE(... testing $cf_cv_header_path_$3)
1042         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1043         AC_TRY_COMPILE([$1],[$2],[
1044             CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1045             cf_cv_find_linkage_$3=maybe
1046             cf_test_CPPFLAGS="$CPPFLAGS"
1047             break],[
1048             CPPFLAGS="$cf_save_CPPFLAGS"
1049             ])
1050       fi
1051     done
1052
1053     if test "$cf_cv_find_linkage_$3" = maybe ; then
1054
1055       CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1056
1057       cf_save_LIBS="$LIBS"
1058       cf_save_LDFLAGS="$LDFLAGS"
1059
1060       ifelse([$6],,,[
1061         CPPFLAGS="$cf_test_CPPFLAGS"
1062         LIBS="-l$3 $7 $cf_save_LIBS"
1063         AC_TRY_LINK([$1],[$2],[
1064             CF_VERBOSE(... found $3 library in system)
1065             cf_cv_find_linkage_$3=yes])
1066             CPPFLAGS="$cf_save_CPPFLAGS"
1067             LIBS="$cf_save_LIBS"
1068             ])
1069
1070       if test "$cf_cv_find_linkage_$3" != yes ; then
1071         CF_LIBRARY_PATH(cf_search,$3)
1072         for cf_cv_library_path_$3 in $cf_search
1073         do
1074           if test -d $cf_cv_library_path_$3 ; then
1075             CF_VERBOSE(... testing $cf_cv_library_path_$3)
1076             CPPFLAGS="$cf_test_CPPFLAGS"
1077             LIBS="-l$3 $7 $cf_save_LIBS"
1078             LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1079             AC_TRY_LINK([$1],[$2],[
1080                 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1081                 cf_cv_find_linkage_$3=yes
1082                 cf_cv_library_file_$3="-l$3"
1083                 break],[
1084                 CPPFLAGS="$cf_save_CPPFLAGS"
1085                 LIBS="$cf_save_LIBS"
1086                 LDFLAGS="$cf_save_LDFLAGS"
1087                 ])
1088           fi
1089         done
1090         CPPFLAGS="$cf_save_CPPFLAGS"
1091         LDFLAGS="$cf_save_LDFLAGS"
1092       fi
1093
1094     else
1095       cf_cv_find_linkage_$3=no
1096     fi
1097     ],$7)
1098 ])
1099
1100 LIBS="$cf_save_LIBS"
1101
1102 if test "$cf_cv_find_linkage_$3" = yes ; then
1103 ifelse([$4],,[
1104         CF_ADD_INCDIR($cf_cv_header_path_$3)
1105         CF_ADD_LIBDIR($cf_cv_library_path_$3)
1106         CF_ADD_LIB($3)
1107 ],[$4])
1108 else
1109 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1110 fi
1111 ])dnl
1112 dnl ---------------------------------------------------------------------------
1113 dnl CF_FUNC_CURSES_VERSION version: 5 updated: 2010/10/23 15:54:49
1114 dnl ----------------------
1115 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
1116 dnl It's a character string "SVR4", not documented.
1117 AC_DEFUN([CF_FUNC_CURSES_VERSION],
1118 [
1119 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
1120 AC_TRY_RUN([
1121 #include <${cf_cv_ncurses_header:-curses.h}>
1122 int main()
1123 {
1124         char temp[1024];
1125         sprintf(temp, "%s\n", curses_version());
1126         ${cf_cv_main_return:-return}(0);
1127 }]
1128 ,[cf_cv_func_curses_version=yes]
1129 ,[cf_cv_func_curses_version=no]
1130 ,[cf_cv_func_curses_version=unknown])
1131 rm -f core])
1132 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
1133 ])
1134 dnl ---------------------------------------------------------------------------
1135 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
1136 dnl -----------------
1137 dnl Test for availability of useful gcc __attribute__ directives to quiet
1138 dnl compiler warnings.  Though useful, not all are supported -- and contrary
1139 dnl to documentation, unrecognized directives cause older compilers to barf.
1140 AC_DEFUN([CF_GCC_ATTRIBUTES],
1141 [
1142 if test "$GCC" = yes
1143 then
1144 cat > conftest.i <<EOF
1145 #ifndef GCC_PRINTF
1146 #define GCC_PRINTF 0
1147 #endif
1148 #ifndef GCC_SCANF
1149 #define GCC_SCANF 0
1150 #endif
1151 #ifndef GCC_NORETURN
1152 #define GCC_NORETURN /* nothing */
1153 #endif
1154 #ifndef GCC_UNUSED
1155 #define GCC_UNUSED /* nothing */
1156 #endif
1157 EOF
1158 if test "$GCC" = yes
1159 then
1160         AC_CHECKING([for $CC __attribute__ directives])
1161 cat > conftest.$ac_ext <<EOF
1162 #line __oline__ "${as_me:-configure}"
1163 #include "confdefs.h"
1164 #include "conftest.h"
1165 #include "conftest.i"
1166 #if     GCC_PRINTF
1167 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1168 #else
1169 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1170 #endif
1171 #if     GCC_SCANF
1172 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1173 #else
1174 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1175 #endif
1176 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1177 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1178 extern void foo(void) GCC_NORETURN;
1179 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1180 EOF
1181         cf_printf_attribute=no
1182         cf_scanf_attribute=no
1183         for cf_attribute in scanf printf unused noreturn
1184         do
1185                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1186                 cf_directive="__attribute__(($cf_attribute))"
1187                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1188
1189                 case $cf_attribute in #(vi
1190                 printf) #(vi
1191                         cf_printf_attribute=yes
1192                         cat >conftest.h <<EOF
1193 #define GCC_$cf_ATTRIBUTE 1
1194 EOF
1195                         ;;
1196                 scanf) #(vi
1197                         cf_scanf_attribute=yes
1198                         cat >conftest.h <<EOF
1199 #define GCC_$cf_ATTRIBUTE 1
1200 EOF
1201                         ;;
1202                 *) #(vi
1203                         cat >conftest.h <<EOF
1204 #define GCC_$cf_ATTRIBUTE $cf_directive
1205 EOF
1206                         ;;
1207                 esac
1208
1209                 if AC_TRY_EVAL(ac_compile); then
1210                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1211                         cat conftest.h >>confdefs.h
1212                         case $cf_attribute in #(vi
1213                         printf) #(vi
1214                                 if test "$cf_printf_attribute" = no ; then
1215                                         cat >>confdefs.h <<EOF
1216 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
1217 EOF
1218                                 else
1219                                         cat >>confdefs.h <<EOF
1220 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1221 EOF
1222                                 fi
1223                                 ;;
1224                         scanf) #(vi
1225                                 if test "$cf_scanf_attribute" = no ; then
1226                                         cat >>confdefs.h <<EOF
1227 #define GCC_SCANFLIKE(fmt,var) /* nothing */
1228 EOF
1229                                 else
1230                                         cat >>confdefs.h <<EOF
1231 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1232 EOF
1233                                 fi
1234                                 ;;
1235                         esac
1236                 fi
1237         done
1238 else
1239         fgrep define conftest.i >>confdefs.h
1240 fi
1241 rm -rf conftest*
1242 fi
1243 ])dnl
1244 dnl ---------------------------------------------------------------------------
1245 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
1246 dnl --------------
1247 dnl Find version of gcc
1248 AC_DEFUN([CF_GCC_VERSION],[
1249 AC_REQUIRE([AC_PROG_CC])
1250 GCC_VERSION=none
1251 if test "$GCC" = yes ; then
1252         AC_MSG_CHECKING(version of $CC)
1253         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1254         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1255         AC_MSG_RESULT($GCC_VERSION)
1256 fi
1257 ])dnl
1258 dnl ---------------------------------------------------------------------------
1259 dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
1260 dnl ---------------
1261 dnl Check if the compiler supports useful warning options.  There's a few that
1262 dnl we don't use, simply because they're too noisy:
1263 dnl
1264 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1265 dnl     -Wredundant-decls (system headers make this too noisy)
1266 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1267 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1268 dnl             is enabled for ncurses using "--enable-const".
1269 dnl     -pedantic
1270 dnl
1271 dnl Parameter:
1272 dnl     $1 is an optional list of gcc warning flags that a particular
1273 dnl             application might want to use, e.g., "no-unused" for
1274 dnl             -Wno-unused
1275 dnl Special:
1276 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1277 dnl
1278 AC_DEFUN([CF_GCC_WARNINGS],
1279 [
1280 AC_REQUIRE([CF_GCC_VERSION])
1281 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1282
1283 cat > conftest.$ac_ext <<EOF
1284 #line __oline__ "${as_me:-configure}"
1285 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1286 EOF
1287
1288 if test "$INTEL_COMPILER" = yes
1289 then
1290 # The "-wdXXX" options suppress warnings:
1291 # remark #1419: external declaration in primary source file
1292 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1293 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1294 # remark #193: zero used for undefined preprocessing identifier
1295 # remark #593: variable "curs_sb_left_arrow" was set but never used
1296 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1297 # remark #869: parameter "tw" was never referenced
1298 # remark #981: operands are evaluated in unspecified order
1299 # warning #279: controlling expression is constant
1300
1301         AC_CHECKING([for $CC warning options])
1302         cf_save_CFLAGS="$CFLAGS"
1303         EXTRA_CFLAGS="-Wall"
1304         for cf_opt in \
1305                 wd1419 \
1306                 wd1683 \
1307                 wd1684 \
1308                 wd193 \
1309                 wd593 \
1310                 wd279 \
1311                 wd810 \
1312                 wd869 \
1313                 wd981
1314         do
1315                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1316                 if AC_TRY_EVAL(ac_compile); then
1317                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1318                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1319                 fi
1320         done
1321         CFLAGS="$cf_save_CFLAGS"
1322
1323 elif test "$GCC" = yes
1324 then
1325         AC_CHECKING([for $CC warning options])
1326         cf_save_CFLAGS="$CFLAGS"
1327         EXTRA_CFLAGS=
1328         cf_warn_CONST=""
1329         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1330         for cf_opt in W Wall \
1331                 Wbad-function-cast \
1332                 Wcast-align \
1333                 Wcast-qual \
1334                 Winline \
1335                 Wmissing-declarations \
1336                 Wmissing-prototypes \
1337                 Wnested-externs \
1338                 Wpointer-arith \
1339                 Wshadow \
1340                 Wstrict-prototypes \
1341                 Wundef $cf_warn_CONST $1
1342         do
1343                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1344                 if AC_TRY_EVAL(ac_compile); then
1345                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1346                         case $cf_opt in #(vi
1347                         Wcast-qual) #(vi
1348                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1349                                 ;;
1350                         Winline) #(vi
1351                                 case $GCC_VERSION in
1352                                 [[34]].*)
1353                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1354                                         continue;;
1355                                 esac
1356                                 ;;
1357                         esac
1358                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1359                 fi
1360         done
1361         CFLAGS="$cf_save_CFLAGS"
1362 fi
1363 rm -rf conftest*
1364
1365 AC_SUBST(EXTRA_CFLAGS)
1366 ])dnl
1367 dnl ---------------------------------------------------------------------------
1368 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1369 dnl -------------
1370 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1371 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1372 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1373 dnl since it is interwoven with GNU extensions.
1374 dnl
1375 dnl Well, yes we could work around it...
1376 AC_DEFUN([CF_GNU_SOURCE],
1377 [
1378 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1379 AC_TRY_COMPILE([#include <sys/types.h>],[
1380 #ifndef _XOPEN_SOURCE
1381 make an error
1382 #endif],
1383         [cf_cv_gnu_source=no],
1384         [cf_save="$CPPFLAGS"
1385          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1386          AC_TRY_COMPILE([#include <sys/types.h>],[
1387 #ifdef _XOPEN_SOURCE
1388 make an error
1389 #endif],
1390         [cf_cv_gnu_source=no],
1391         [cf_cv_gnu_source=yes])
1392         CPPFLAGS="$cf_save"
1393         ])
1394 ])
1395 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1396 ])dnl
1397 dnl ---------------------------------------------------------------------------
1398 dnl CF_HEADER_PATH version: 12 updated: 2010/05/05 05:22:40
1399 dnl --------------
1400 dnl Construct a search-list of directories for a nonstandard header-file
1401 dnl
1402 dnl Parameters
1403 dnl     $1 = the variable to return as result
1404 dnl     $2 = the package name
1405 AC_DEFUN([CF_HEADER_PATH],
1406 [
1407 $1=
1408
1409 # collect the current set of include-directories from compiler flags
1410 cf_header_path_list=""
1411 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1412         for cf_header_path in $CPPFLAGS $CFLAGS
1413         do
1414                 case $cf_header_path in #(vi
1415                 -I*)
1416                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1417                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1418                         cf_header_path_list="$cf_header_path_list [$]$1"
1419                         ;;
1420                 esac
1421         done
1422 fi
1423
1424 # add the variations for the package we are looking for
1425 CF_SUBDIR_PATH($1,$2,include)
1426
1427 test "$includedir" != NONE && \
1428 test "$includedir" != "/usr/include" && \
1429 test -d "$includedir" && {
1430         test -d $includedir &&    $1="[$]$1 $includedir"
1431         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1432 }
1433
1434 test "$oldincludedir" != NONE && \
1435 test "$oldincludedir" != "/usr/include" && \
1436 test -d "$oldincludedir" && {
1437         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1438         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1439 }
1440
1441 $1="[$]$1 $cf_header_path_list"
1442 ])dnl
1443 dnl ---------------------------------------------------------------------------
1444 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
1445 dnl -----------------
1446 dnl If we do not have a given script, look for it in the parent directory.
1447 AC_DEFUN([CF_INHERIT_SCRIPT],
1448 [
1449 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1450 ])dnl
1451 dnl ---------------------------------------------------------------------------
1452 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
1453 dnl -----------------
1454 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1455 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1456 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1457 dnl
1458 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1459 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1460 dnl the wrappers for gcc and g++ warnings.
1461 dnl
1462 dnl $1 = GCC (default) or GXX
1463 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1464 dnl $3 = CFLAGS (default) or CXXFLAGS
1465 AC_DEFUN([CF_INTEL_COMPILER],[
1466 ifelse([$2],,INTEL_COMPILER,[$2])=no
1467
1468 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1469         case $host_os in
1470         linux*|gnu*)
1471                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1472                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1473                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1474                 AC_TRY_COMPILE([],[
1475 #ifdef __INTEL_COMPILER
1476 #else
1477 make an error
1478 #endif
1479 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1480 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1481 ],[])
1482                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1483                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1484                 ;;
1485         esac
1486 fi
1487 ])dnl
1488 dnl ---------------------------------------------------------------------------
1489 dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
1490 dnl ---------------
1491 dnl Construct a search-list of directories for a nonstandard library-file
1492 dnl
1493 dnl Parameters
1494 dnl     $1 = the variable to return as result
1495 dnl     $2 = the package name
1496 AC_DEFUN([CF_LIBRARY_PATH],
1497 [
1498 $1=
1499 cf_library_path_list=""
1500 if test -n "${LDFLAGS}${LIBS}" ; then
1501         for cf_library_path in $LDFLAGS $LIBS
1502         do
1503                 case $cf_library_path in #(vi
1504                 -L*)
1505                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1506                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1507                         cf_library_path_list="$cf_library_path_list [$]$1"
1508                         ;;
1509                 esac
1510         done
1511 fi
1512
1513 CF_SUBDIR_PATH($1,$2,lib)
1514
1515 $1="$cf_library_path_list [$]$1"
1516 ])dnl
1517 dnl ---------------------------------------------------------------------------
1518 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1519 dnl ------------
1520 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1521 dnl a monocase filesystem.
1522 AC_DEFUN([CF_MAKE_TAGS],[
1523 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1524
1525 AC_CHECK_PROGS(CTAGS, exctags ctags)
1526 AC_CHECK_PROGS(ETAGS, exetags etags)
1527
1528 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1529
1530 if test "$cf_cv_mixedcase" = yes ; then
1531         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1532 else
1533         MAKE_UPPER_TAGS=no
1534 fi
1535
1536 if test "$MAKE_UPPER_TAGS" = yes ; then
1537         MAKE_UPPER_TAGS=
1538 else
1539         MAKE_UPPER_TAGS="#"
1540 fi
1541
1542 if test "$MAKE_LOWER_TAGS" = yes ; then
1543         MAKE_LOWER_TAGS=
1544 else
1545         MAKE_LOWER_TAGS="#"
1546 fi
1547
1548 AC_SUBST(CTAGS)
1549 AC_SUBST(ETAGS)
1550
1551 AC_SUBST(MAKE_UPPER_TAGS)
1552 AC_SUBST(MAKE_LOWER_TAGS)
1553 ])dnl
1554 dnl ---------------------------------------------------------------------------
1555 dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
1556 dnl -----------
1557 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
1558 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
1559 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1560 AC_DEFUN([CF_MATH_LIB],
1561 [
1562 AC_CACHE_CHECK(if -lm needed for math functions,
1563         cf_cv_need_libm,[
1564         AC_TRY_LINK([
1565         #include <stdio.h>
1566         #include <math.h>
1567         ],
1568         [double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
1569         [cf_cv_need_libm=no],
1570         [cf_cv_need_libm=yes])])
1571 if test "$cf_cv_need_libm" = yes
1572 then
1573 ifelse($1,,[
1574         CF_ADD_LIB(m)
1575 ],[$1=-lm])
1576 fi
1577 ])
1578 dnl ---------------------------------------------------------------------------
1579 dnl CF_MIN_GETCCHAR version: 3 updated: 2010/10/23 15:54:49
1580 dnl ---------------
1581 dnl CF_MIN_GETCCHAR
1582 dnl Check whether getcchar's return value counts the trailing null in a wchar_t
1583 dnl string, or not.  X/Open says it does, but Tru64 and Solaris do not do this.
1584 AC_DEFUN([CF_MIN_GETCCHAR],[
1585 AC_CACHE_CHECK(if getcchar counts trailing null,cf_cv_min_getcchar,[
1586 AC_TRY_RUN([
1587 #include <stdlib.h>
1588 #include <stdarg.h>
1589 #include <${cf_cv_ncurses_header:-curses.h}>
1590
1591 int main()
1592 {
1593         wchar_t data[2];
1594         cchar_t temp[2];
1595         int count;
1596         data[0] = L'\0';
1597     setcchar(temp, data, 0, 0, (void *)0);
1598         count = getcchar(temp, (wchar_t *)0, (attr_t *)0, (short *)0, (void *)0);
1599         ${cf_cv_main_return:-return}(count != 0);
1600 }],
1601         [cf_cv_min_getcchar=no],
1602         [cf_cv_min_getcchar=yes],
1603         [cf_cv_min_getcchar=yes])
1604 ])
1605 if test "$cf_cv_min_getcchar" = yes ; then
1606         AC_DEFINE(MIN_GETCCHAR,1)
1607 fi
1608 ])dnl
1609 dnl ---------------------------------------------------------------------------
1610 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
1611 dnl ----------------------
1612 dnl Check if the file-system supports mixed-case filenames.  If we're able to
1613 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1614 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1615 [
1616 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1617 if test "$cross_compiling" = yes ; then
1618         case $target_alias in #(vi
1619         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
1620                 cf_cv_mixedcase=no
1621                 ;;
1622         *)
1623                 cf_cv_mixedcase=yes
1624                 ;;
1625         esac
1626 else
1627         rm -f conftest CONFTEST
1628         echo test >conftest
1629         if test -f CONFTEST ; then
1630                 cf_cv_mixedcase=no
1631         else
1632                 cf_cv_mixedcase=yes
1633         fi
1634         rm -f conftest CONFTEST
1635 fi
1636 ])
1637 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1638 ])dnl
1639 dnl ---------------------------------------------------------------------------
1640 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1641 dnl ----------
1642 dnl Write a debug message to config.log, along with the line number in the
1643 dnl configure script.
1644 AC_DEFUN([CF_MSG_LOG],[
1645 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1646 ])dnl
1647 dnl ---------------------------------------------------------------------------
1648 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1649 dnl -------------------
1650 dnl Check if we can compile with ncurses' header file
1651 dnl $1 is the cache variable to set
1652 dnl $2 is the header-file to include
1653 dnl $3 is the root name (ncurses or ncursesw)
1654 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1655         AC_TRY_COMPILE([
1656 ]ifelse($3,ncursesw,[
1657 #define _XOPEN_SOURCE_EXTENDED
1658 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
1659 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
1660 ])[
1661 #include <$2>],[
1662 #ifdef NCURSES_VERSION
1663 ]ifelse($3,ncursesw,[
1664 #ifndef WACS_BSSB
1665         make an error
1666 #endif
1667 ])[
1668 printf("%s\n", NCURSES_VERSION);
1669 #else
1670 #ifdef __NCURSES_H
1671 printf("old\n");
1672 #else
1673         make an error
1674 #endif
1675 #endif
1676         ]
1677         ,[$1=$2]
1678         ,[$1=no])
1679 ])dnl
1680 dnl ---------------------------------------------------------------------------
1681 dnl CF_NCURSES_CONFIG version: 8 updated: 2010/07/08 05:17:30
1682 dnl -----------------
1683 dnl Tie together the configure-script macros for ncurses.
1684 dnl Prefer the "-config" script from ncurses 6.x, to simplify analysis.
1685 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
1686 dnl
1687 dnl $1 is the root library name (default: "ncurses")
1688 AC_DEFUN([CF_NCURSES_CONFIG],
1689 [
1690 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1691
1692 echo "Looking for ${cf_ncuconfig_root}-config"
1693 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
1694
1695 if test "$NCURSES_CONFIG" != none ; then
1696
1697 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1698 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
1699
1700 # even with config script, some packages use no-override for curses.h
1701 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
1702
1703 dnl like CF_NCURSES_CPPFLAGS
1704 AC_DEFINE(NCURSES)
1705
1706 dnl like CF_NCURSES_LIBS
1707 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1708 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1709
1710 dnl like CF_NCURSES_VERSION
1711 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1712
1713 else
1714
1715 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1716 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1717
1718 fi
1719 ])dnl
1720 dnl ---------------------------------------------------------------------------
1721 dnl CF_NCURSES_CPPFLAGS version: 20 updated: 2010/11/20 17:02:38
1722 dnl -------------------
1723 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1724 dnl the CPPFLAGS variable so we can include its header.
1725 dnl
1726 dnl The header files may be installed as either curses.h, or ncurses.h (would
1727 dnl be obsolete, except that some packagers prefer this name to distinguish it
1728 dnl from a "native" curses implementation).  If not installed for overwrite,
1729 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1730 dnl /usr/include/ncurses), but someone may have installed overwriting the
1731 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
1732 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1733 dnl the header.
1734 dnl
1735 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1736 dnl is already in the include-path, don't even bother with this, since we cannot
1737 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
1738 dnl
1739 dnl The optional parameter gives the root name of the library, in case it is
1740 dnl not installed as the default curses library.  That is how the
1741 dnl wide-character version of ncurses is installed.
1742 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1743 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1744
1745 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1746 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1747
1748 test -n "$cf_cv_curses_dir" && \
1749 test "$cf_cv_curses_dir" != "no" && { \
1750   CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
1751 }
1752
1753 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1754         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1755         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1756         for cf_header in $cf_header_list
1757         do
1758                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1759                 test "$cf_cv_ncurses_h" != no && break
1760         done
1761 ])
1762
1763 CF_NCURSES_HEADER
1764 CF_TERM_HEADER
1765
1766 # some applications need this, but should check for NCURSES_VERSION
1767 AC_DEFINE(NCURSES)
1768
1769 CF_NCURSES_VERSION
1770 ])dnl
1771 dnl ---------------------------------------------------------------------------
1772 dnl CF_NCURSES_EXT_FUNCS version: 3 updated: 2010/11/13 19:43:23
1773 dnl --------------------
1774 dnl Since 2007/11/17, ncurses has defined NCURSES_EXT_FUNCS; earlier versions
1775 dnl may provide these functions.  Define the symbol if it is not defined, and
1776 dnl if it is valid.
1777 AC_DEFUN([CF_NCURSES_EXT_FUNCS],
1778 [
1779 AC_CACHE_CHECK(for ncurses extended functions,cf_cv_ncurses_ext_funcs,[
1780 AC_TRY_COMPILE([
1781 #include <${cf_cv_ncurses_header:-curses.h}>],
1782 [
1783 int x = NCURSES_EXT_FUNCS
1784 ],[cf_cv_ncurses_ext_funcs=defined],[
1785 AC_TRY_LINK([
1786 #include <${cf_cv_ncurses_header:-curses.h}>],
1787 [
1788         (void) assume_default_colors (0, 0);
1789         (void) curses_version ();
1790         (void) define_key (0, 0);
1791         (void) is_term_resized (0, 0);
1792         (void) key_defined (0);
1793         (void) keybound (0, 0);
1794         (void) keyok (0, 0);
1795         (void) resize_term (0, 0);
1796         (void) resizeterm (0, 0);
1797         (void) use_default_colors ();
1798         (void) use_extended_names (0);
1799         (void) wresize (0, 0, 0);],
1800         [cf_cv_ncurses_ext_funcs=yes],
1801         [cf_cv_ncurses_ext_funcs=no])
1802 ])
1803 ])
1804 test "$cf_cv_ncurses_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS)
1805 ])dnl
1806 dnl ---------------------------------------------------------------------------
1807 dnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
1808 dnl -----------------
1809 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1810 dnl variations of ncurses' installs.
1811 dnl
1812 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1813 AC_DEFUN([CF_NCURSES_HEADER],[
1814
1815 if test "$cf_cv_ncurses_h" != no ; then
1816         cf_cv_ncurses_header=$cf_cv_ncurses_h
1817 else
1818
1819 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1820         test -n "$verbose" && echo
1821         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1822         test -n "$verbose" && echo search path $cf_search
1823         cf_save2_CPPFLAGS="$CPPFLAGS"
1824         for cf_incdir in $cf_search
1825         do
1826                 CF_ADD_INCDIR($cf_incdir)
1827                 for cf_header in \
1828                         ncurses.h \
1829                         curses.h
1830                 do
1831                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1832                         if test "$cf_cv_ncurses_h2" != no ; then
1833                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1834                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
1835                                 break
1836                         fi
1837                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1838                 done
1839                 CPPFLAGS="$cf_save2_CPPFLAGS"
1840                 test "$cf_cv_ncurses_h2" != no && break
1841         done
1842         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
1843         ])
1844
1845         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1846         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1847         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1848                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1849         fi
1850         CF_ADD_INCDIR($cf_1st_incdir)
1851
1852 fi
1853
1854 # Set definitions to allow ifdef'ing for ncurses.h
1855
1856 case $cf_cv_ncurses_header in # (vi
1857 *ncurses.h)
1858         AC_DEFINE(HAVE_NCURSES_H)
1859         ;;
1860 esac
1861
1862 case $cf_cv_ncurses_header in # (vi
1863 ncurses/curses.h|ncurses/ncurses.h)
1864         AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1865         ;;
1866 ncursesw/curses.h|ncursesw/ncurses.h)
1867         AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1868         ;;
1869 esac
1870
1871 ])dnl
1872 dnl ---------------------------------------------------------------------------
1873 dnl CF_NCURSES_LIBS version: 16 updated: 2010/11/20 17:02:38
1874 dnl ---------------
1875 dnl Look for the ncurses library.  This is a little complicated on Linux,
1876 dnl because it may be linked with the gpm (general purpose mouse) library.
1877 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1878 dnl unusable with ncurses.  However, we don't want to link with gpm unless
1879 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1880 dnl and the linker will record a dependency.
1881 dnl
1882 dnl The optional parameter gives the root name of the library, in case it is
1883 dnl not installed as the default curses library.  That is how the
1884 dnl wide-character version of ncurses is installed.
1885 AC_DEFUN([CF_NCURSES_LIBS],
1886 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1887
1888 cf_nculib_root=ifelse($1,,ncurses,$1)
1889         # This works, except for the special case where we find gpm, but
1890         # ncurses is in a nonstandard location via $LIBS, and we really want
1891         # to link gpm.
1892 cf_ncurses_LIBS=""
1893 cf_ncurses_SAVE="$LIBS"
1894 AC_CHECK_LIB(gpm,Gpm_Open,
1895         [AC_CHECK_LIB(gpm,initscr,
1896                 [LIBS="$cf_ncurses_SAVE"],
1897                 [cf_ncurses_LIBS="-lgpm"])])
1898
1899 case $host_os in #(vi
1900 freebsd*)
1901         # This is only necessary if you are linking against an obsolete
1902         # version of ncurses (but it should do no harm, since it's static).
1903         if test "$cf_nculib_root" = ncurses ; then
1904                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1905         fi
1906         ;;
1907 esac
1908
1909 CF_ADD_LIBS($cf_ncurses_LIBS)
1910
1911 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1912 then
1913         CF_ADD_LIBS(-l$cf_nculib_root)
1914 else
1915         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1916                 [#include <${cf_cv_ncurses_header:-curses.h}>],
1917                 [initscr()],
1918                 initscr)
1919 fi
1920
1921 if test -n "$cf_ncurses_LIBS" ; then
1922         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1923         cf_ncurses_SAVE="$LIBS"
1924         for p in $cf_ncurses_LIBS ; do
1925                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1926                 if test "$q" != "$LIBS" ; then
1927                         LIBS="$q"
1928                 fi
1929         done
1930         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1931                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1932                 [AC_MSG_RESULT(yes)],
1933                 [AC_MSG_RESULT(no)
1934                  LIBS="$cf_ncurses_SAVE"])
1935 fi
1936
1937 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1938 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1939 ])dnl
1940 dnl ---------------------------------------------------------------------------
1941 dnl CF_NCURSES_VERSION version: 13 updated: 2010/10/23 15:54:49
1942 dnl ------------------
1943 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1944 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
1945 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1946 AC_DEFUN([CF_NCURSES_VERSION],
1947 [
1948 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1949 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1950         cf_cv_ncurses_version=no
1951         cf_tempfile=out$$
1952         rm -f $cf_tempfile
1953         AC_TRY_RUN([
1954 #include <${cf_cv_ncurses_header:-curses.h}>
1955 #include <stdio.h>
1956 int main()
1957 {
1958         FILE *fp = fopen("$cf_tempfile", "w");
1959 #ifdef NCURSES_VERSION
1960 # ifdef NCURSES_VERSION_PATCH
1961         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1962 # else
1963         fprintf(fp, "%s\n", NCURSES_VERSION);
1964 # endif
1965 #else
1966 # ifdef __NCURSES_H
1967         fprintf(fp, "old\n");
1968 # else
1969         make an error
1970 # endif
1971 #endif
1972         ${cf_cv_main_return:-return}(0);
1973 }],[
1974         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1975
1976         # This will not work if the preprocessor splits the line after the
1977         # Autoconf token.  The 'unproto' program does that.
1978         cat > conftest.$ac_ext <<EOF
1979 #include <${cf_cv_ncurses_header:-curses.h}>
1980 #undef Autoconf
1981 #ifdef NCURSES_VERSION
1982 Autoconf NCURSES_VERSION
1983 #else
1984 #ifdef __NCURSES_H
1985 Autoconf "old"
1986 #endif
1987 ;
1988 #endif
1989 EOF
1990         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1991         AC_TRY_EVAL(cf_try)
1992         if test -f conftest.out ; then
1993                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1994                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1995                 rm -f conftest.out
1996         fi
1997 ])
1998         rm -f $cf_tempfile
1999 ])
2000 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
2001 ])dnl
2002 dnl ---------------------------------------------------------------------------
2003 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
2004 dnl ----------------------
2005 dnl Check for ncurses "wrap-prefix" used for public variables which have been
2006 dnl wrapped with a function to help with concurrency control.
2007 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
2008 [
2009 AC_MSG_CHECKING(for ncurses wrap-prefix)
2010 AC_ARG_WITH(ncurses-wrap-prefix,
2011         [  --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
2012         [NCURSES_WRAP_PREFIX=$withval],
2013         [NCURSES_WRAP_PREFIX=_nc_])
2014 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
2015
2016 AC_SUBST(NCURSES_WRAP_PREFIX)
2017 ])
2018 dnl ---------------------------------------------------------------------------
2019 dnl CF_NETBSD_FORM_H version: 1 updated: 2011/01/15 14:59:18
2020 dnl ----------------
2021 dnl Check for NetBSD's form.h, which is incompatible with SVr4 and ncurses.
2022 dnl Some workarounds are needed in client programs to allow them to compile.
2023 AC_DEFUN([CF_NETBSD_FORM_H],[
2024 AC_CACHE_CHECK(for NetBSD form.h,cf_cv_netbsd_form_h,[
2025 AC_TRY_COMPILE([
2026 #include <${cf_cv_ncurses_header:-curses.h}>
2027 #include <form.h>
2028 ],[
2029         FORM *form;
2030         int y = current_field(form)->cursor_ypos;
2031         int x = current_field(form)->cursor_xpos;
2032 ],[cf_cv_netbsd_form_h=yes
2033 ],[cf_cv_netbsd_form_h=no])
2034 ])
2035
2036 test "$cf_cv_netbsd_form_h" = yes && AC_DEFINE(HAVE_NETBSD_FORM_H)
2037 ])dnl
2038 dnl ---------------------------------------------------------------------------
2039 dnl CF_NETBSD_MENU_H version: 1 updated: 2011/01/15 14:59:18
2040 dnl ----------------
2041 dnl Check for NetBSD's menu.h, which is incompatible with SVr4 and ncurses.
2042 dnl Some workarounds are needed in client programs to allow them to compile.
2043 AC_DEFUN([CF_NETBSD_MENU_H],[
2044 AC_CACHE_CHECK(for NetBSD menu.h,cf_cv_netbsd_menu_h,[
2045 AC_TRY_COMPILE([
2046 #include <${cf_cv_ncurses_header:-curses.h}>
2047 #include <menu.h>
2048 ],[
2049         MENU *menu;
2050         int y = menu->max_item_width;
2051 ],[cf_cv_netbsd_menu_h=yes
2052 ],[cf_cv_netbsd_menu_h=no])
2053 ])
2054
2055 test "$cf_cv_netbsd_menu_h" = yes && AC_DEFINE(HAVE_NETBSD_MENU_H)
2056 ])dnl
2057 dnl ---------------------------------------------------------------------------
2058 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
2059 dnl ------------------
2060 dnl see CF_WITH_NO_LEAKS
2061 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2062 AC_MSG_CHECKING(if you want to use $1 for testing)
2063 AC_ARG_WITH($1,
2064         [$2],
2065         [AC_DEFINE($3)ifelse([$4],,[
2066          $4
2067 ])
2068         : ${with_cflags:=-g}
2069         : ${with_no_leaks:=yes}
2070          with_$1=yes],
2071         [with_$1=])
2072 AC_MSG_RESULT(${with_$1:-no})
2073
2074 case .$with_cflags in #(vi
2075 .*-g*)
2076         case .$CFLAGS in #(vi
2077         .*-g*) #(vi
2078                 ;;
2079         *)
2080                 CF_ADD_CFLAGS([-g])
2081                 ;;
2082         esac
2083         ;;
2084 esac
2085 ])dnl
2086 dnl ---------------------------------------------------------------------------
2087 dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
2088 dnl --------------
2089 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2090 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2091 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2092 dnl delayed evaluation of those symbols.
2093 AC_DEFUN([CF_PATH_SYNTAX],[
2094 if test "x$prefix" != xNONE; then
2095   cf_path_syntax="$prefix"
2096 else
2097   cf_path_syntax="$ac_default_prefix"
2098 fi
2099
2100 case ".[$]$1" in #(vi
2101 .\[$]\(*\)*|.\'*\'*) #(vi
2102   ;;
2103 ..|./*|.\\*) #(vi
2104   ;;
2105 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
2106   ;;
2107 .\[$]{*prefix}*) #(vi
2108   eval $1="[$]$1"
2109   case ".[$]$1" in #(vi
2110   .NONE/*)
2111     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2112     ;;
2113   esac
2114   ;; #(vi
2115 .no|.NONE/*)
2116   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2117   ;;
2118 *)
2119   ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2120   ;;
2121 esac
2122 ])dnl
2123 dnl ---------------------------------------------------------------------------
2124 dnl CF_PDCURSES_X11 version: 11 updated: 2011/01/15 18:45:38
2125 dnl ---------------
2126 dnl Configure for PDCurses' X11 library
2127 AC_DEFUN([CF_PDCURSES_X11],[
2128 AC_REQUIRE([CF_X_ATHENA])
2129
2130 AC_PATH_PROGS(XCURSES_CONFIG,xcurses-config,none)
2131
2132 if test "$XCURSES_CONFIG" != none ; then
2133
2134 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
2135 CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
2136
2137 cf_cv_lib_XCurses=yes
2138
2139 else
2140
2141 LDFLAGS="$LDFLAGS $X_LIBS"
2142 CF_CHECK_CFLAGS($X_CFLAGS)
2143 AC_CHECK_LIB(X11,XOpenDisplay,
2144         [CF_ADD_LIBS(-lX11)],,
2145         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
2146 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
2147 CF_ADD_LIBS(-lXCurses)
2148 AC_TRY_LINK([
2149 #include <xcurses.h>
2150 char *XCursesProgramName = "test";
2151 ],[XCursesExit();],
2152 [cf_cv_lib_XCurses=yes],
2153 [cf_cv_lib_XCurses=no])
2154 ])
2155
2156 fi
2157
2158 if test $cf_cv_lib_XCurses = yes ; then
2159         AC_DEFINE(UNIX)
2160         AC_DEFINE(XCURSES)
2161         AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES))
2162 else
2163         AC_MSG_ERROR(Cannot link with XCurses)
2164 fi
2165 ])dnl
2166 dnl ---------------------------------------------------------------------------
2167 dnl CF_PKG_CONFIG version: 3 updated: 2009/01/25 10:55:09
2168 dnl -------------
2169 dnl Check for the package-config program, unless disabled by command-line.
2170 AC_DEFUN([CF_PKG_CONFIG],
2171 [
2172 AC_MSG_CHECKING(if you want to use pkg-config)
2173 AC_ARG_WITH(pkg-config,
2174         [  --with-pkg-config{=path} enable/disable use of pkg-config],
2175         [cf_pkg_config=$withval],
2176         [cf_pkg_config=yes])
2177 AC_MSG_RESULT($cf_pkg_config)
2178
2179 case $cf_pkg_config in #(vi
2180 no) #(vi
2181         PKG_CONFIG=none
2182         ;;
2183 yes) #(vi
2184         AC_PATH_PROG(PKG_CONFIG, pkg-config, none)
2185         ;;
2186 *)
2187         PKG_CONFIG=$withval
2188         ;;
2189 esac
2190
2191 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2192 if test "$PKG_CONFIG" != none ; then
2193         CF_PATH_SYNTAX(PKG_CONFIG)
2194 fi
2195
2196 AC_SUBST(PKG_CONFIG)
2197 ])dnl
2198 dnl ---------------------------------------------------------------------------
2199 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
2200 dnl -----------------
2201 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2202 dnl
2203 dnl     POSIX.1-1990                            _POSIX_SOURCE
2204 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
2205 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
2206 dnl             Bindings Option
2207 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
2208 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
2209 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
2210 dnl
2211 dnl Parameters:
2212 dnl     $1 is the nominal value for _POSIX_C_SOURCE
2213 AC_DEFUN([CF_POSIX_C_SOURCE],
2214 [
2215 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2216
2217 cf_save_CFLAGS="$CFLAGS"
2218 cf_save_CPPFLAGS="$CPPFLAGS"
2219
2220 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2221 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2222
2223 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2224         CF_MSG_LOG(if the symbol is already defined go no further)
2225         AC_TRY_COMPILE([#include <sys/types.h>],[
2226 #ifndef _POSIX_C_SOURCE
2227 make an error
2228 #endif],
2229         [cf_cv_posix_c_source=no],
2230         [cf_want_posix_source=no
2231          case .$cf_POSIX_C_SOURCE in #(vi
2232          .[[12]]??*) #(vi
2233                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2234                 ;;
2235          .2) #(vi
2236                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2237                 cf_want_posix_source=yes
2238                 ;;
2239          .*)
2240                 cf_want_posix_source=yes
2241                 ;;
2242          esac
2243          if test "$cf_want_posix_source" = yes ; then
2244                 AC_TRY_COMPILE([#include <sys/types.h>],[
2245 #ifdef _POSIX_SOURCE
2246 make an error
2247 #endif],[],
2248                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2249          fi
2250          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2251          CFLAGS="$cf_trim_CFLAGS"
2252          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2253          CF_MSG_LOG(if the second compile does not leave our definition intact error)
2254          AC_TRY_COMPILE([#include <sys/types.h>],[
2255 #ifndef _POSIX_C_SOURCE
2256 make an error
2257 #endif],,
2258          [cf_cv_posix_c_source=no])
2259          CFLAGS="$cf_save_CFLAGS"
2260          CPPFLAGS="$cf_save_CPPFLAGS"
2261         ])
2262 ])
2263
2264 if test "$cf_cv_posix_c_source" != no ; then
2265         CFLAGS="$cf_trim_CFLAGS"
2266         CPPFLAGS="$cf_trim_CPPFLAGS"
2267         CF_ADD_CFLAGS($cf_cv_posix_c_source)
2268 fi
2269
2270 ])dnl
2271 dnl ---------------------------------------------------------------------------
2272 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
2273 dnl ------------
2274 dnl Append definitions and rules for the given programs to the subdirectory
2275 dnl Makefiles, and the recursion rule for the top-level Makefile.
2276 dnl
2277 dnl parameters
2278 dnl     $1 = script to run
2279 dnl     $2 = list of subdirectories
2280 dnl
2281 dnl variables
2282 dnl     $AWK
2283 AC_DEFUN([CF_PRG_RULES],
2284 [
2285 for cf_dir in $2
2286 do
2287         if test ! -d $srcdir/$cf_dir; then
2288                 continue
2289         elif test -f $srcdir/$cf_dir/programs; then
2290                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
2291         fi
2292 done
2293
2294 ])dnl
2295 dnl ---------------------------------------------------------------------------
2296 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
2297 dnl --------------
2298 dnl Check if C (preprocessor) -U and -D options are processed in the order
2299 dnl given rather than by type of option.  Some compilers insist on apply all
2300 dnl of the -U options after all of the -D options.  Others allow mixing them,
2301 dnl and may predefine symbols that conflict with those we define.
2302 AC_DEFUN([CF_PROG_CC_U_D],
2303 [
2304 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
2305         cf_save_CPPFLAGS="$CPPFLAGS"
2306         CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
2307         AC_TRY_COMPILE([],[
2308 #ifndef U_D_OPTIONS
2309 make an undefined-error
2310 #endif
2311 #ifdef  D_U_OPTIONS
2312 make a defined-error
2313 #endif
2314         ],[
2315         cf_cv_cc_u_d_options=yes],[
2316         cf_cv_cc_u_d_options=no])
2317         CPPFLAGS="$cf_save_CPPFLAGS"
2318 ])
2319 ])dnl
2320 dnl ---------------------------------------------------------------------------
2321 dnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
2322 dnl ---------------
2323 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
2324 dnl misc/tabset install won't work properly.  Usually this happens only when
2325 dnl using the fallback mkinstalldirs script
2326 AC_DEFUN([CF_PROG_INSTALL],
2327 [AC_PROG_INSTALL
2328 case $INSTALL in
2329 /*)
2330   ;;
2331 *)
2332   CF_DIRNAME(cf_dir,$INSTALL)
2333   test -z "$cf_dir" && cf_dir=.
2334   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
2335   ;;
2336 esac
2337 ])dnl
2338 dnl ---------------------------------------------------------------------------
2339 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
2340 dnl ------------
2341 AC_DEFUN([CF_PROG_LINT],
2342 [
2343 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
2344 AC_SUBST(LINT_OPTS)
2345 ])dnl
2346 dnl ---------------------------------------------------------------------------
2347 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2348 dnl ----------------
2349 dnl Remove all -U and -D options that refer to the given symbol from a list
2350 dnl of C compiler options.  This works around the problem that not all
2351 dnl compilers process -U and -D options from left-to-right, so a -U option
2352 dnl cannot be used to cancel the effect of a preceding -D option.
2353 dnl
2354 dnl $1 = target (which could be the same as the source variable)
2355 dnl $2 = source (including '$')
2356 dnl $3 = symbol to remove
2357 define([CF_REMOVE_DEFINE],
2358 [
2359 $1=`echo "$2" | \
2360         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
2361                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
2362 ])dnl
2363 dnl ---------------------------------------------------------------------------
2364 dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
2365 dnl ---------------
2366 dnl signal handler, but there are some gcc depedencies in that recommendation.
2367 dnl Try anyway.
2368 AC_DEFUN([CF_SIG_ATOMIC_T],
2369 [
2370 AC_MSG_CHECKING(for signal global datatype)
2371 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2372         for cf_type in \
2373                 "volatile sig_atomic_t" \
2374                 "sig_atomic_t" \
2375                 "int"
2376         do
2377         AC_TRY_COMPILE([
2378 #include <sys/types.h>
2379 #include <signal.h>
2380 #include <stdio.h>
2381
2382 extern $cf_type x;
2383 $cf_type x;
2384 static void handler(int sig)
2385 {
2386         x = 5;
2387 }],
2388                 [signal(SIGINT, handler);
2389                  x = 1],
2390                 [cf_cv_sig_atomic_t=$cf_type],
2391                 [cf_cv_sig_atomic_t=no])
2392                 test "$cf_cv_sig_atomic_t" != no && break
2393         done
2394         ])
2395 AC_MSG_RESULT($cf_cv_sig_atomic_t)
2396 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
2397 ])dnl
2398 dnl ---------------------------------------------------------------------------
2399 dnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
2400 dnl --------------
2401 dnl Construct a search-list for a nonstandard header/lib-file
2402 dnl     $1 = the variable to return as result
2403 dnl     $2 = the package name
2404 dnl     $3 = the subdirectory, e.g., bin, include or lib
2405 AC_DEFUN([CF_SUBDIR_PATH],
2406 [
2407 $1=
2408
2409 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
2410 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
2411 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
2412 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
2413 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
2414 ])dnl
2415 dnl ---------------------------------------------------------------------------
2416 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
2417 dnl ------------------
2418 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2419 dnl older SCO configurations.
2420 AC_DEFUN([CF_SYS_TIME_SELECT],
2421 [
2422 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2423 AC_CACHE_VAL(cf_cv_sys_time_select,[
2424 AC_TRY_COMPILE([
2425 #include <sys/types.h>
2426 #ifdef HAVE_SYS_TIME_H
2427 #include <sys/time.h>
2428 #endif
2429 #ifdef HAVE_SYS_SELECT_H
2430 #include <sys/select.h>
2431 #endif
2432 ],[],[cf_cv_sys_time_select=yes],
2433      [cf_cv_sys_time_select=no])
2434      ])
2435 AC_MSG_RESULT($cf_cv_sys_time_select)
2436 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2437 ])dnl
2438 dnl ---------------------------------------------------------------------------
2439 dnl CF_TERM_HEADER version: 2 updated: 2010/10/23 15:54:49
2440 dnl --------------
2441 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
2442 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
2443 dnl but some packagers change this, breaking various applications.
2444 AC_DEFUN([CF_TERM_HEADER],[
2445 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2446 case ${cf_cv_ncurses_header} in #(vi
2447 */ncurses.h|*/ncursesw.h) #(vi
2448         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2449         ;;
2450 *)
2451         cf_term_header=term.h
2452         ;;
2453 esac
2454
2455 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2456 do
2457 AC_TRY_COMPILE([#include <stdio.h>
2458 #include <${cf_cv_ncurses_header:-curses.h}>
2459 #include <$cf_test>
2460 ],[int x = auto_left_margin],[
2461         cf_cv_term_header="$cf_test"],[
2462         cf_cv_term_header=unknown
2463         ])
2464         test "$cf_cv_term_header" != unknown && break
2465 done
2466 ])
2467
2468 # Set definitions to allow ifdef'ing to accommodate subdirectories
2469
2470 case $cf_cv_term_header in # (vi
2471 *term.h)
2472         AC_DEFINE(HAVE_TERM_H)
2473         ;;
2474 esac
2475
2476 case $cf_cv_term_header in # (vi
2477 ncurses/term.h) #(vi
2478         AC_DEFINE(HAVE_NCURSES_TERM_H)
2479         ;;
2480 ncursesw/term.h)
2481         AC_DEFINE(HAVE_NCURSESW_TERM_H)
2482         ;;
2483 esac
2484 ])dnl
2485 dnl ---------------------------------------------------------------------------
2486 dnl CF_TRY_PKG_CONFIG version: 4 updated: 2010/06/14 17:42:30
2487 dnl -----------------
2488 dnl This is a simple wrapper to use for pkg-config, for libraries which may be
2489 dnl available in that form.
2490 dnl
2491 dnl $1 = package name
2492 dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
2493 dnl $3 = logic to use if pkg-config does not have the package
2494 AC_DEFUN([CF_TRY_PKG_CONFIG],[
2495 AC_REQUIRE([CF_PKG_CONFIG])
2496
2497 if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
2498         CF_VERBOSE(found package $1)
2499         cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
2500         cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
2501         CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
2502         CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
2503         CF_ADD_CFLAGS($cf_pkgconfig_incs)
2504         CF_ADD_LIBS($cf_pkgconfig_libs)
2505         ifelse([$2],,:,[$2])
2506 else
2507         ifelse([$3],,:,[$3])
2508 fi
2509 ])
2510 dnl ---------------------------------------------------------------------------
2511 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2512 dnl --------
2513 dnl Make an uppercase version of a variable
2514 dnl $1=uppercase($2)
2515 AC_DEFUN([CF_UPPER],
2516 [
2517 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2518 ])dnl
2519 dnl ---------------------------------------------------------------------------
2520 dnl CF_UTF8_LIB version: 7 updated: 2010/06/20 09:24:28
2521 dnl -----------
2522 dnl Check for multibyte support, and if not found, utf8 compatibility library
2523 AC_DEFUN([CF_UTF8_LIB],
2524 [
2525 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
2526         cf_save_LIBS="$LIBS"
2527         AC_TRY_LINK([
2528 #include <stdlib.h>],[putwc(0,0);],
2529         [cf_cv_utf8_lib=yes],
2530         [CF_FIND_LINKAGE([
2531 #include <libutf8.h>],[putwc(0,0);],utf8,
2532                 [cf_cv_utf8_lib=add-on],
2533                 [cf_cv_utf8_lib=no])
2534 ])])
2535
2536 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
2537 # ncurses/ncursesw:
2538 if test "$cf_cv_utf8_lib" = "add-on" ; then
2539         AC_DEFINE(HAVE_LIBUTF8_H)
2540         CF_ADD_INCDIR($cf_cv_header_path_utf8)
2541         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
2542         CF_ADD_LIBS($cf_cv_library_file_utf8)
2543 fi
2544 ])dnl
2545 dnl ---------------------------------------------------------------------------
2546 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2547 dnl ----------
2548 dnl Use AC_VERBOSE w/o the warnings
2549 AC_DEFUN([CF_VERBOSE],
2550 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
2551 CF_MSG_LOG([$1])
2552 ])dnl
2553 dnl ---------------------------------------------------------------------------
2554 dnl CF_WCHAR_TYPE version: 3 updated: 2010/05/26 16:44:57
2555 dnl -------------
2556 dnl Check if type wide-character type $1 is declared, and if so, which header
2557 dnl file is needed.  The second parameter is used to set a shell variable when
2558 dnl the type is not found.  The first parameter sets a shell variable for the
2559 dnl opposite sense.
2560 AC_DEFUN([CF_WCHAR_TYPE],
2561 [
2562 # This is needed on Tru64 5.0 to declare $1
2563 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
2564 AC_TRY_COMPILE([
2565 #include <stdlib.h>
2566 #include <stdarg.h>
2567 #include <stdio.h>
2568 #ifdef HAVE_LIBUTF8_H
2569 #include <libutf8.h>
2570 #endif],
2571         [$1 state],
2572         [cf_cv_$1=no],
2573         [AC_TRY_COMPILE([
2574 #include <stdlib.h>
2575 #include <stdarg.h>
2576 #include <stdio.h>
2577 #include <wchar.h>
2578 #ifdef HAVE_LIBUTF8_H
2579 #include <libutf8.h>
2580 #endif],
2581         [$1 value],
2582         [cf_cv_$1=yes],
2583         [cf_cv_$1=unknown])])])
2584
2585 if test "$cf_cv_$1" = yes ; then
2586         AC_DEFINE(NEED_WCHAR_H)
2587         NEED_WCHAR_H=1
2588 fi
2589
2590 ifelse([$2],,,[
2591 # if we do not find $1 in either place, use substitution to provide a fallback.
2592 if test "$cf_cv_$1" = unknown ; then
2593         $2=1
2594 fi
2595 ])
2596 ifelse($3,,,[
2597 # if we find $1 in either place, use substitution to provide a fallback.
2598 if test "$cf_cv_$1" != unknown ; then
2599         $3=1
2600 fi
2601 ])
2602 ])dnl
2603 dnl ---------------------------------------------------------------------------
2604 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
2605 dnl ------------------
2606 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
2607 dnl libraries.
2608 AC_DEFUN([CF_WITH_CURSES_DIR],[
2609
2610 AC_MSG_CHECKING(for specific curses-directory)
2611 AC_ARG_WITH(curses-dir,
2612         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
2613         [cf_cv_curses_dir=$withval],
2614         [cf_cv_curses_dir=no])
2615 AC_MSG_RESULT($cf_cv_curses_dir)
2616
2617 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2618 then
2619         CF_PATH_SYNTAX(withval)
2620         if test -d "$cf_cv_curses_dir"
2621         then
2622                 CF_ADD_INCDIR($cf_cv_curses_dir/include)
2623                 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
2624         fi
2625 fi
2626 ])dnl
2627 dnl ---------------------------------------------------------------------------
2628 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
2629 dnl ----------------
2630 dnl Configure-option for dbmalloc.  The optional parameter is used to override
2631 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
2632 AC_DEFUN([CF_WITH_DBMALLOC],[
2633 CF_NO_LEAKS_OPTION(dbmalloc,
2634         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
2635         [USE_DBMALLOC])
2636
2637 if test "$with_dbmalloc" = yes ; then
2638         AC_CHECK_HEADER(dbmalloc.h,
2639                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
2640 fi
2641 ])dnl
2642 dnl ---------------------------------------------------------------------------
2643 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
2644 dnl ---------------
2645 dnl Configure-option for dmalloc.  The optional parameter is used to override
2646 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
2647 AC_DEFUN([CF_WITH_DMALLOC],[
2648 CF_NO_LEAKS_OPTION(dmalloc,
2649         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
2650         [USE_DMALLOC])
2651
2652 if test "$with_dmalloc" = yes ; then
2653         AC_CHECK_HEADER(dmalloc.h,
2654                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
2655 fi
2656 ])dnl
2657 dnl ---------------------------------------------------------------------------
2658 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
2659 dnl ----------------
2660 AC_DEFUN([CF_WITH_VALGRIND],[
2661 CF_NO_LEAKS_OPTION(valgrind,
2662         [  --with-valgrind         test: use valgrind],
2663         [USE_VALGRIND])
2664 ])dnl
2665 dnl ---------------------------------------------------------------------------
2666 dnl CF_XOPEN_CURSES version: 10 updated: 2010/10/23 15:54:49
2667 dnl ---------------
2668 dnl Test if we should define X/Open source for curses, needed on Digital Unix
2669 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
2670 dnl
2671 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
2672 dnl as getbegy().  The latter is better design, but the former is standard.
2673 AC_DEFUN([CF_XOPEN_CURSES],
2674 [
2675 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2676 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
2677 AC_TRY_LINK([
2678 #include <stdlib.h>
2679 #include <${cf_cv_ncurses_header:-curses.h}>],[
2680 #if defined(NCURSES_VERSION_PATCH)
2681 if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
2682         make an error
2683 #endif
2684 #endif
2685         long x = winnstr(stdscr, "", 0);
2686         int x1, y1;
2687         getbegyx(stdscr, y1, x1)],
2688         [cf_cv_need_xopen_extension=no],
2689         [AC_TRY_LINK([
2690 #define _XOPEN_SOURCE_EXTENDED
2691 #include <stdlib.h>
2692 #include <${cf_cv_ncurses_header:-curses.h}>],[
2693 #ifdef NCURSES_VERSION
2694         cchar_t check;
2695         int check2 = curs_set((int)sizeof(check));
2696 #endif
2697         long x = winnstr(stdscr, "", 0);
2698         int x1, y1;
2699         getbegyx(stdscr, y1, x1)],
2700         [cf_cv_need_xopen_extension=yes],
2701         [cf_cv_need_xopen_extension=unknown])])])
2702 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
2703 ])dnl
2704 dnl ---------------------------------------------------------------------------
2705 dnl CF_XOPEN_SOURCE version: 34 updated: 2010/05/26 05:38:42
2706 dnl ---------------
2707 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2708 dnl or adapt to the vendor's definitions to get equivalent functionality,
2709 dnl without losing the common non-POSIX features.
2710 dnl
2711 dnl Parameters:
2712 dnl     $1 is the nominal value for _XOPEN_SOURCE
2713 dnl     $2 is the nominal value for _POSIX_C_SOURCE
2714 AC_DEFUN([CF_XOPEN_SOURCE],[
2715
2716 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
2717 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
2718 cf_xopen_source=
2719
2720 case $host_os in #(vi
2721 aix[[456]]*) #(vi
2722         cf_xopen_source="-D_ALL_SOURCE"
2723         ;;
2724 darwin[[0-8]].*) #(vi
2725         cf_xopen_source="-D_APPLE_C_SOURCE"
2726         ;;
2727 darwin*) #(vi
2728         cf_xopen_source="-D_DARWIN_C_SOURCE"
2729         ;;
2730 freebsd*|dragonfly*) #(vi
2731         # 5.x headers associate
2732         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2733         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2734         cf_POSIX_C_SOURCE=200112L
2735         cf_XOPEN_SOURCE=600
2736         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2737         ;;
2738 hpux11*) #(vi
2739         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
2740         ;;
2741 hpux*) #(vi
2742         cf_xopen_source="-D_HPUX_SOURCE"
2743         ;;
2744 irix[[56]].*) #(vi
2745         cf_xopen_source="-D_SGI_SOURCE"
2746         ;;
2747 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
2748         CF_GNU_SOURCE
2749         ;;
2750 mirbsd*) #(vi
2751         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
2752         ;;
2753 netbsd*) #(vi
2754         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2755         ;;
2756 openbsd*) #(vi
2757         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2758         ;;
2759 osf[[45]]*) #(vi
2760         cf_xopen_source="-D_OSF_SOURCE"
2761         ;;
2762 nto-qnx*) #(vi
2763         cf_xopen_source="-D_QNX_SOURCE"
2764         ;;
2765 sco*) #(vi
2766         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2767         ;;
2768 solaris2.1[[0-9]]) #(vi
2769         cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2770         ;;
2771 solaris2.[[1-9]]) #(vi
2772         cf_xopen_source="-D__EXTENSIONS__"
2773         ;;
2774 *)
2775         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2776         AC_TRY_COMPILE([#include <sys/types.h>],[
2777 #ifndef _XOPEN_SOURCE
2778 make an error
2779 #endif],
2780         [cf_cv_xopen_source=no],
2781         [cf_save="$CPPFLAGS"
2782          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2783          AC_TRY_COMPILE([#include <sys/types.h>],[
2784 #ifdef _XOPEN_SOURCE
2785 make an error
2786 #endif],
2787         [cf_cv_xopen_source=no],
2788         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2789         CPPFLAGS="$cf_save"
2790         ])
2791 ])
2792         if test "$cf_cv_xopen_source" != no ; then
2793                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2794                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2795                 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
2796                 CF_ADD_CFLAGS($cf_temp_xopen_source)
2797         fi
2798         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2799         ;;
2800 esac
2801
2802 if test -n "$cf_xopen_source" ; then
2803         CF_ADD_CFLAGS($cf_xopen_source)
2804 fi
2805 ])
2806 dnl ---------------------------------------------------------------------------
2807 dnl CF_X_ATHENA version: 20 updated: 2010/11/09 05:18:02
2808 dnl -----------
2809 dnl Check for Xaw (Athena) libraries
2810 dnl
2811 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
2812 AC_DEFUN([CF_X_ATHENA],
2813 [
2814 cf_x_athena=${cf_x_athena:-Xaw}
2815
2816 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
2817 withval=
2818 AC_ARG_WITH(Xaw3d,
2819         [  --with-Xaw3d            link with Xaw 3d library])
2820 if test "$withval" = yes ; then
2821         cf_x_athena=Xaw3d
2822         AC_MSG_RESULT(yes)
2823 else
2824         AC_MSG_RESULT(no)
2825 fi
2826
2827 AC_MSG_CHECKING(if you want to link with neXT Athena library)
2828 withval=
2829 AC_ARG_WITH(neXtaw,
2830         [  --with-neXtaw           link with neXT Athena library])
2831 if test "$withval" = yes ; then
2832         cf_x_athena=neXtaw
2833         AC_MSG_RESULT(yes)
2834 else
2835         AC_MSG_RESULT(no)
2836 fi
2837
2838 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
2839 withval=
2840 AC_ARG_WITH(XawPlus,
2841         [  --with-XawPlus          link with Athena-Plus library])
2842 if test "$withval" = yes ; then
2843         cf_x_athena=XawPlus
2844         AC_MSG_RESULT(yes)
2845 else
2846         AC_MSG_RESULT(no)
2847 fi
2848
2849 cf_x_athena_lib=""
2850
2851 if test "$PKG_CONFIG" != none ; then
2852         cf_athena_list=
2853         test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
2854         for cf_athena_pkg in \
2855                 $cf_athena_list \
2856                 ${cf_x_athena} \
2857                 ${cf_x_athena}-devel \
2858                 lib${cf_x_athena} \
2859                 lib${cf_x_athena}-devel
2860         do
2861                 CF_TRY_PKG_CONFIG($cf_athena_pkg,[
2862                         cf_x_athena_lib="$cf_pkgconfig_libs"
2863                         CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2864                         AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2865
2866 AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
2867 AC_TRY_LINK([
2868 #include <X11/Xmu/CharSet.h>
2869 ],[
2870 int check = XmuCompareISOLatin1("big", "small")
2871 ],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
2872
2873                         if test "$cf_cv_xaw_compat" = no
2874                         then
2875                                 # workaround for broken ".pc" files...
2876                                 case "$cf_x_athena_lib" in #(vi
2877                                 *-lXmu*) #(vi
2878                                         ;;
2879                                 *)
2880                                         CF_VERBOSE(work around broken package)
2881                                         CF_TRY_PKG_CONFIG(xmu,,[CF_ADD_LIB_AFTER(-lXt,-lXmu)])
2882                                         ;;
2883                                 esac
2884                         fi
2885
2886                         break])
2887         done
2888 fi
2889
2890 if test -z "$cf_x_athena_lib" ; then
2891         CF_X_EXT
2892         CF_X_TOOLKIT
2893         CF_X_ATHENA_CPPFLAGS($cf_x_athena)
2894         CF_X_ATHENA_LIBS($cf_x_athena)
2895 fi
2896 ])dnl
2897 dnl ---------------------------------------------------------------------------
2898 dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
2899 dnl --------------------
2900 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2901 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2902 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
2903 [
2904 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
2905 cf_x_athena_inc=""
2906
2907 for cf_path in default \
2908         /usr/contrib/X11R6 \
2909         /usr/contrib/X11R5 \
2910         /usr/lib/X11R5 \
2911         /usr/local
2912 do
2913         if test -z "$cf_x_athena_inc" ; then
2914                 cf_save="$CPPFLAGS"
2915                 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
2916                 if test $cf_path != default ; then
2917                         CPPFLAGS="$cf_save -I$cf_path/include"
2918                         AC_MSG_CHECKING(for $cf_test in $cf_path)
2919                 else
2920                         AC_MSG_CHECKING(for $cf_test)
2921                 fi
2922                 AC_TRY_COMPILE([
2923 #include <X11/Intrinsic.h>
2924 #include <$cf_test>],[],
2925                         [cf_result=yes],
2926                         [cf_result=no])
2927                 AC_MSG_RESULT($cf_result)
2928                 if test "$cf_result" = yes ; then
2929                         cf_x_athena_inc=$cf_path
2930                         break
2931                 else
2932                         CPPFLAGS="$cf_save"
2933                 fi
2934         fi
2935 done
2936
2937 if test -z "$cf_x_athena_inc" ; then
2938         AC_MSG_WARN(
2939 [Unable to successfully find Athena header files with test program])
2940 elif test "$cf_x_athena_inc" != default ; then
2941         CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
2942 fi
2943 ])
2944 dnl ---------------------------------------------------------------------------
2945 dnl CF_X_ATHENA_LIBS version: 9 updated: 2010/06/02 05:03:05
2946 dnl ----------------
2947 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2948 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2949 AC_DEFUN([CF_X_ATHENA_LIBS],
2950 [AC_REQUIRE([CF_X_TOOLKIT])
2951 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
2952 cf_x_athena_lib=""
2953
2954 for cf_path in default \
2955         /usr/contrib/X11R6 \
2956         /usr/contrib/X11R5 \
2957         /usr/lib/X11R5 \
2958         /usr/local
2959 do
2960         for cf_lib in \
2961                 "-l$cf_x_athena_root -lXmu" \
2962                 "-l$cf_x_athena_root -lXpm -lXmu" \
2963                 "-l${cf_x_athena_root}_s -lXmu_s"
2964         do
2965                 if test -z "$cf_x_athena_lib" ; then
2966                         cf_save="$LIBS"
2967                         cf_test=XawSimpleMenuAddGlobalActions
2968                         if test $cf_path != default ; then
2969                                 CF_ADD_LIBS(-L$cf_path/lib $cf_lib)
2970                                 AC_MSG_CHECKING(for $cf_lib in $cf_path)
2971                         else
2972                                 CF_ADD_LIBS($cf_lib)
2973                                 AC_MSG_CHECKING(for $cf_test in $cf_lib)
2974                         fi
2975                         AC_TRY_LINK([],[$cf_test()],
2976                                 [cf_result=yes],
2977                                 [cf_result=no])
2978                         AC_MSG_RESULT($cf_result)
2979                         if test "$cf_result" = yes ; then
2980                                 cf_x_athena_lib="$cf_lib"
2981                                 break
2982                         fi
2983                         LIBS="$cf_save"
2984                 fi
2985         done
2986 done
2987
2988 if test -z "$cf_x_athena_lib" ; then
2989         AC_MSG_ERROR(
2990 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
2991 fi
2992
2993 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2994 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2995 ])
2996 dnl ---------------------------------------------------------------------------
2997 dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
2998 dnl --------
2999 AC_DEFUN([CF_X_EXT],[
3000 CF_TRY_PKG_CONFIG(Xext,,[
3001         AC_CHECK_LIB(Xext,XextCreateExtension,
3002                 [CF_ADD_LIB(Xext)])])
3003 ])dnl
3004 dnl ---------------------------------------------------------------------------
3005 dnl CF_X_TOOLKIT version: 20 updated: 2010/11/19 05:43:04
3006 dnl ------------
3007 dnl Check for X Toolkit libraries
3008 dnl
3009 AC_DEFUN([CF_X_TOOLKIT],
3010 [
3011 AC_REQUIRE([AC_PATH_XTRA])
3012 AC_REQUIRE([CF_CHECK_CACHE])
3013
3014 cf_have_X_LIBS=no
3015
3016 CF_TRY_PKG_CONFIG(xt,[
3017
3018         case "x$LIBS" in #(vi
3019         *-lX11*) #(vi
3020                 ;;
3021         *)
3022 # we have an "xt" package, but it may omit Xt's dependency on X11
3023 AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
3024 AC_TRY_LINK([
3025 #include <X11/Xlib.h>
3026 ],[
3027         int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
3028         int rc2 = XClearWindow((Display*) 0, (Window) 0);
3029         int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
3030         int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
3031 ],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
3032                 if test "$cf_cv_xt_x11_compat" = no
3033                 then
3034                         CF_VERBOSE(work around broken X11 dependency)
3035                         # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
3036                         CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
3037                 fi
3038                 ;;
3039         esac
3040
3041 AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
3042 AC_TRY_LINK([
3043 #include <X11/Shell.h>
3044 ],[int num = IceConnectionNumber(0)
3045 ],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
3046
3047         if test "$cf_cv_xt_ice_compat" = no
3048         then
3049                 # workaround for broken ".pc" files used for X Toolkit.
3050                 case "x$X_PRE_LIBS" in #(vi
3051                 *-lICE*)
3052                         case "x$LIBS" in #(vi
3053                         *-lICE*) #(vi
3054                                 ;;
3055                         *)
3056                                 CF_VERBOSE(work around broken ICE dependency)
3057                                 CF_TRY_PKG_CONFIG(ice,
3058                                         [CF_TRY_PKG_CONFIG(sm)],
3059                                         [CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
3060                                 ;;
3061                         esac
3062                         ;;
3063                 esac
3064         fi
3065
3066         cf_have_X_LIBS=yes
3067 ],[
3068
3069         LDFLAGS="$X_LIBS $LDFLAGS"
3070         CF_CHECK_CFLAGS($X_CFLAGS)
3071
3072         AC_CHECK_FUNC(XOpenDisplay,,[
3073         AC_CHECK_LIB(X11,XOpenDisplay,
3074                 [CF_ADD_LIB(X11)],,
3075                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3076
3077         AC_CHECK_FUNC(XtAppInitialize,,[
3078         AC_CHECK_LIB(Xt, XtAppInitialize,
3079                 [AC_DEFINE(HAVE_LIBXT)
3080                  cf_have_X_LIBS=Xt
3081                  LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
3082                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3083 ])
3084
3085 if test $cf_have_X_LIBS = no ; then
3086         AC_MSG_WARN(
3087 [Unable to successfully link X Toolkit library (-lXt) with
3088 test program.  You will have to check and add the proper libraries by hand
3089 to makefile.])
3090 fi
3091 ])dnl
3092 dnl ---------------------------------------------------------------------------
3093 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
3094 dnl ---------------
3095 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
3096 dnl are both available.
3097 define([CF__CURSES_HEAD],[
3098 #ifdef HAVE_XCURSES
3099 #include <xcurses.h>
3100 char * XCursesProgramName = "test";
3101 #else
3102 #include <${cf_cv_ncurses_header:-curses.h}>
3103 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
3104 #include <ncursesw/term.h>
3105 #elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
3106 #include <ncurses/term.h>
3107 #elif defined(HAVE_TERM_H)
3108 #include <term.h>
3109 #endif
3110 #endif
3111 ])