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