]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/aclocal.m4
ncurses 5.7 - patch 20100227
[ncurses.git] / test / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2003-2008,2009 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.29 2009/07/17 01:07:50 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: 8 updated: 2009/01/06 19:33:30
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                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
86                         ;;
87                 esac
88                 ;;
89         *)
90                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
91                 ;;
92         esac
93         ;;
94 yes)
95         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
96
97         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
98
99         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
100         && test -z "${cf_tst_cflags}" \
101         && cf_fix_cppflags=no
102         ;;
103 esac
104 done
105
106 if test -n "$cf_new_cflags" ; then
107         ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
108         CFLAGS="$CFLAGS $cf_new_cflags"
109 fi
110
111 if test -n "$cf_new_cppflags" ; then
112         ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
113         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
114 fi
115
116 if test -n "$cf_new_extra_cppflags" ; then
117         ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
118         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
119 fi
120
121 AC_SUBST(EXTRA_CPPFLAGS)
122
123 ])dnl
124 dnl ---------------------------------------------------------------------------
125 dnl CF_ADD_INCDIR version: 12 updated: 2009/01/18 10:00:47
126 dnl -------------
127 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
128 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
129 dnl but old versions (and some misinstalled ones) need that.  To make things
130 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
131 dnl the include-path).
132 AC_DEFUN([CF_ADD_INCDIR],
133 [
134 if test -n "$1" ; then
135   for cf_add_incdir in $1
136   do
137         while test $cf_add_incdir != /usr/include
138         do
139           if test -d $cf_add_incdir
140           then
141                 cf_have_incdir=no
142                 if test -n "$CFLAGS$CPPFLAGS" ; then
143                   # a loop is needed to ensure we can add subdirs of existing dirs
144                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
145                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
146                           cf_have_incdir=yes; break
147                         fi
148                   done
149                 fi
150
151                 if test "$cf_have_incdir" = no ; then
152                   if test "$cf_add_incdir" = /usr/local/include ; then
153                         if test "$GCC" = yes
154                         then
155                           cf_save_CPPFLAGS=$CPPFLAGS
156                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
157                           AC_TRY_COMPILE([#include <stdio.h>],
158                                   [printf("Hello")],
159                                   [],
160                                   [cf_have_incdir=yes])
161                           CPPFLAGS=$cf_save_CPPFLAGS
162                         fi
163                   fi
164                 fi
165
166                 if test "$cf_have_incdir" = no ; then
167                   CF_VERBOSE(adding $cf_add_incdir to include-path)
168                   ifelse($2,,CPPFLAGS,$2)="$ifelse($2,,CPPFLAGS,$2) -I$cf_add_incdir"
169
170                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
171                   test "$cf_top_incdir" = "$cf_add_incdir" && break
172                   cf_add_incdir="$cf_top_incdir"
173                 else
174                   break
175                 fi
176           fi
177         done
178   done
179 fi
180 ])dnl
181 dnl ---------------------------------------------------------------------------
182 dnl CF_ADD_LIBDIR version: 8 updated: 2009/01/18 10:01:08
183 dnl -------------
184 dnl     Adds to the library-path
185 dnl
186 dnl     Some machines have trouble with multiple -L options.
187 dnl
188 dnl $1 is the (list of) directory(s) to add
189 dnl $2 is the optional name of the variable to update (default LDFLAGS)
190 dnl
191 AC_DEFUN([CF_ADD_LIBDIR],
192 [
193 if test -n "$1" ; then
194   for cf_add_libdir in $1
195   do
196     if test $cf_add_libdir = /usr/lib ; then
197       :
198     elif test -d $cf_add_libdir
199     then
200       cf_have_libdir=no
201       if test -n "$LDFLAGS$LIBS" ; then
202         # a loop is needed to ensure we can add subdirs of existing dirs
203         for cf_test_libdir in $LDFLAGS $LIBS ; do
204           if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
205             cf_have_libdir=yes; break
206           fi
207         done
208       fi
209       if test "$cf_have_libdir" = no ; then
210         CF_VERBOSE(adding $cf_add_libdir to library-path)
211         ifelse($2,,LDFLAGS,$2)="-L$cf_add_libdir $ifelse($2,,LDFLAGS,$2)"
212       fi
213     fi
214   done
215 fi
216 ])dnl
217 dnl ---------------------------------------------------------------------------
218 dnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
219 dnl ------------------
220 dnl Append to a search-list for a nonstandard header/lib-file
221 dnl     $1 = the variable to return as result
222 dnl     $2 = the package name
223 dnl     $3 = the subdirectory, e.g., bin, include or lib
224 dnl $4 = the directory under which we will test for subdirectories
225 dnl $5 = a directory that we do not want $4 to match
226 AC_DEFUN([CF_ADD_SUBDIR_PATH],
227 [
228 test "$4" != "$5" && \
229 test -d "$4" && \
230 ifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
231         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
232         test -d $4/$3 &&          $1="[$]$1 $4/$3"
233         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
234         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
235         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
236         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
237 }
238 ])dnl
239 dnl ---------------------------------------------------------------------------
240 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
241 dnl ----------------
242 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
243 dnl in the sharutils 4.2 distribution.
244 AC_DEFUN([CF_ANSI_CC_CHECK],
245 [
246 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
247 cf_cv_ansi_cc=no
248 cf_save_CFLAGS="$CFLAGS"
249 cf_save_CPPFLAGS="$CPPFLAGS"
250 # Don't try gcc -ansi; that turns off useful extensions and
251 # breaks some systems' header files.
252 # AIX                   -qlanglvl=ansi
253 # Ultrix and OSF/1      -std1
254 # HP-UX                 -Aa -D_HPUX_SOURCE
255 # SVR4                  -Xc
256 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
257 for cf_arg in "-DCC_HAS_PROTOS" \
258         "" \
259         -qlanglvl=ansi \
260         -std1 \
261         -Ae \
262         "-Aa -D_HPUX_SOURCE" \
263         -Xc
264 do
265         CF_ADD_CFLAGS($cf_arg)
266         AC_TRY_COMPILE(
267 [
268 #ifndef CC_HAS_PROTOS
269 #if !defined(__STDC__) || (__STDC__ != 1)
270 choke me
271 #endif
272 #endif
273 ],[
274         int test (int i, double x);
275         struct s1 {int (*f) (int a);};
276         struct s2 {int (*f) (double a);};],
277         [cf_cv_ansi_cc="$cf_arg"; break])
278 done
279 CFLAGS="$cf_save_CFLAGS"
280 CPPFLAGS="$cf_save_CPPFLAGS"
281 ])
282
283 if test "$cf_cv_ansi_cc" != "no"; then
284 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
285         CF_ADD_CFLAGS($cf_cv_ansi_cc)
286 else
287         AC_DEFINE(CC_HAS_PROTOS)
288 fi
289 fi
290 ])dnl
291 dnl ---------------------------------------------------------------------------
292 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
293 dnl ---------------
294 dnl For programs that must use an ANSI compiler, obtain compiler options that
295 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
296 dnl macros, since tools such as unproto can fake prototypes, but only part of
297 dnl the preprocessor.
298 AC_DEFUN([CF_ANSI_CC_REQD],
299 [AC_REQUIRE([CF_ANSI_CC_CHECK])
300 if test "$cf_cv_ansi_cc" = "no"; then
301         AC_MSG_ERROR(
302 [Your compiler does not appear to recognize prototypes.
303 You have the following choices:
304         a. adjust your compiler options
305         b. get an up-to-date compiler
306         c. use a wrapper such as unproto])
307 fi
308 ])dnl
309 dnl ---------------------------------------------------------------------------
310 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
311 dnl --------------
312 dnl Allow user to disable a normally-on option.
313 AC_DEFUN([CF_ARG_DISABLE],
314 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
315 dnl ---------------------------------------------------------------------------
316 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
317 dnl -------------
318 dnl Allow user to enable a normally-off option.
319 AC_DEFUN([CF_ARG_ENABLE],
320 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
321 dnl ---------------------------------------------------------------------------
322 dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
323 dnl -------------
324 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
325 dnl values.
326 dnl
327 dnl Parameters:
328 dnl $1 = option name
329 dnl $2 = help-string
330 dnl $3 = action to perform if option is not default
331 dnl $4 = action if perform if option is default
332 dnl $5 = default option value (either 'yes' or 'no')
333 AC_DEFUN([CF_ARG_OPTION],
334 [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
335   if test "$enableval" != "$5" ; then
336 ifelse($3,,[    :]dnl
337 ,[    $3]) ifelse($4,,,[
338   else
339     $4])
340   fi],[enableval=$5 ifelse($4,,,[
341   $4
342 ])dnl
343   ])])dnl
344 dnl ---------------------------------------------------------------------------
345 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
346 dnl --------------
347 dnl Check if we're accidentally using a cache from a different machine.
348 dnl Derive the system name, as a check for reusing the autoconf cache.
349 dnl
350 dnl If we've packaged config.guess and config.sub, run that (since it does a
351 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
352 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
353 dnl which is useful in cross-compiles.
354 dnl
355 dnl Note: we would use $ac_config_sub, but that is one of the places where
356 dnl autoconf 2.5x broke compatibility with autoconf 2.13
357 AC_DEFUN([CF_CHECK_CACHE],
358 [
359 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
360         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
361         system_name="$host_os"
362 else
363         system_name="`(uname -s -r) 2>/dev/null`"
364         if test -z "$system_name" ; then
365                 system_name="`(hostname) 2>/dev/null`"
366         fi
367 fi
368 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
369 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
370
371 test -z "$system_name" && system_name="$cf_cv_system_name"
372 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
373
374 if test ".$system_name" != ".$cf_cv_system_name" ; then
375         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
376         AC_MSG_ERROR("Please remove config.cache and try again.")
377 fi
378 ])dnl
379 dnl ---------------------------------------------------------------------------
380 dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
381 dnl ---------------
382 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
383 dnl a build-configuration such as imake.  These have the pitfall that they
384 dnl often contain compiler-specific options which we cannot use, mixed with
385 dnl preprocessor options that we usually can.
386 AC_DEFUN([CF_CHECK_CFLAGS],
387 [
388 CF_VERBOSE(checking additions to CFLAGS)
389 cf_check_cflags="$CFLAGS"
390 cf_check_cppflags="$CPPFLAGS"
391 CF_ADD_CFLAGS($1,yes)
392 if test "$cf_check_cflags" != "$CFLAGS" ; then
393 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
394         [CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
395          if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
396                  CF_VERBOSE(but keeping change to \$CPPFLAGS)
397          fi
398          CFLAGS="$cf_check_flags"])
399 fi
400 ])dnl
401 dnl ---------------------------------------------------------------------------
402 dnl CF_CURSES_ACS_MAP version: 5 updated: 2009/03/28 16:08:10
403 dnl -----------------
404 dnl Check for likely values of acs_map[]:
405 AC_DEFUN([CF_CURSES_ACS_MAP],
406 [
407 AC_REQUIRE([CF_NCURSES_WRAP_PREFIX])dnl
408 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
409 cf_cv_curses_acs_map=unknown
410 for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
411 do
412 AC_TRY_LINK([
413 #include <${cf_cv_ncurses_header-curses.h}>
414 ],[
415 $name['k'] = ACS_PLUS
416 ],[cf_cv_curses_acs_map=$name; break])
417 done
418 ])
419
420 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
421 ])
422 dnl ---------------------------------------------------------------------------
423 dnl CF_CURSES_CHECK_DATA version: 2 updated: 2009/07/16 21:03:10
424 dnl --------------------
425 dnl Check if curses.h defines the given data/variable.
426 dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
427 AC_DEFUN([CF_CURSES_CHECK_DATA],
428 [
429 AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header-curses.h})
430 AC_TRY_COMPILE(CF__CURSES_HEAD,[
431 void *foo = &($1)
432 ],cf_result=yes,cf_result=no)
433 AC_MSG_RESULT($cf_result)
434 if test $cf_result = yes ; then
435         CF_UPPER(cf_result,have_curses_data_$1)
436         AC_DEFINE_UNQUOTED($cf_result)
437 else
438         AC_MSG_CHECKING(for data $1 in library)
439         AC_TRY_LINK(CF__CURSES_HEAD
440 [extern char $1;],[
441         do {
442                 void *foo = &($1);
443                 ${cf_cv_main_return-return}(foo == 0);
444         } while (0)
445 ],[cf_result=yes],[cf_result=no])
446         AC_MSG_RESULT($cf_result)
447         if test $cf_result = yes ; then
448                 CF_UPPER(cf_result,decl_curses_data_$1)
449                 AC_DEFINE_UNQUOTED($cf_result)
450         fi
451 fi
452 ])dnl
453 dnl ---------------------------------------------------------------------------
454 dnl CF_CURSES_CHECK_TYPE version: 2 updated: 2003/03/01 23:40:33
455 dnl --------------------
456 dnl Check if curses.h defines the given type
457 AC_DEFUN([CF_CURSES_CHECK_TYPE],
458 [
459 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header-curses.h})
460 AC_TRY_COMPILE([
461 #ifndef _XOPEN_SOURCE_EXTENDED
462 #define _XOPEN_SOURCE_EXTENDED
463 #endif
464 #include <${cf_cv_ncurses_header-curses.h}>],[
465 $1 foo
466 ],cf_result=yes,cf_result=no)
467 AC_MSG_RESULT($cf_result)
468 if test $cf_result = yes ; then
469         CF_UPPER(cf_result,have_type_$1)
470         AC_DEFINE_UNQUOTED($cf_result)
471 else
472         AC_DEFINE_UNQUOTED($1,$2)
473 fi
474 ])dnl
475 dnl ---------------------------------------------------------------------------
476 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
477 dnl ----------------
478 dnl Tie together the configure-script macros for curses.  It may be ncurses,
479 dnl but unless asked, we do not make a special search for ncurses.  However,
480 dnl still check for the ncurses version number, for use in other macros.
481 AC_DEFUN([CF_CURSES_CONFIG],
482 [
483 CF_CURSES_CPPFLAGS
484 CF_NCURSES_VERSION
485 CF_CURSES_LIBS
486 ])dnl
487 dnl ---------------------------------------------------------------------------
488 dnl CF_CURSES_CPPFLAGS version: 10 updated: 2009/01/06 19:34:11
489 dnl ------------------
490 dnl Look for the curses headers.
491 AC_DEFUN([CF_CURSES_CPPFLAGS],[
492
493 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
494 cf_cv_curses_incdir=no
495 case $host_os in #(vi
496 hpux10.*) #(vi
497         test -d /usr/include/curses_colr && \
498         cf_cv_curses_incdir="-I/usr/include/curses_colr"
499         ;;
500 sunos3*|sunos4*)
501         test -d /usr/5lib && \
502         test -d /usr/5include && \
503         cf_cv_curses_incdir="-I/usr/5include"
504         ;;
505 esac
506 ])
507 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
508
509 CF_CURSES_HEADER
510 CF_TERM_HEADER
511 ])dnl
512 dnl ---------------------------------------------------------------------------
513 dnl CF_CURSES_FUNCS version: 14 updated: 2009/07/16 19:34:55
514 dnl ---------------
515 dnl Curses-functions are a little complicated, since a lot of them are macros.
516 AC_DEFUN([CF_CURSES_FUNCS],
517 [
518 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
519 AC_REQUIRE([CF_XOPEN_CURSES])
520 AC_REQUIRE([CF_CURSES_TERM_H])
521 for cf_func in $1
522 do
523         CF_UPPER(cf_tr_func,$cf_func)
524         AC_MSG_CHECKING(for ${cf_func})
525         CF_MSG_LOG(${cf_func})
526         AC_CACHE_VAL(cf_cv_func_$cf_func,[
527                 eval cf_result='$ac_cv_func_'$cf_func
528                 if test ".$cf_result" != ".no"; then
529                         AC_TRY_LINK(CF__CURSES_HEAD,
530                         [
531 #ifndef ${cf_func}
532 long foo = (long)(&${cf_func});
533 ${cf_cv_main_return-return}(foo == 0);
534 #endif
535                         ],
536                         [cf_result=yes],
537                         [cf_result=no])
538                 fi
539                 eval 'cf_cv_func_'$cf_func'=$cf_result'
540         ])
541         # use the computed/retrieved cache-value:
542         eval 'cf_result=$cf_cv_func_'$cf_func
543         AC_MSG_RESULT($cf_result)
544         if test $cf_result != no; then
545                 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
546         fi
547 done
548 ])dnl
549 dnl ---------------------------------------------------------------------------
550 dnl CF_CURSES_HEADER version: 1 updated: 2005/12/31 13:28:25
551 dnl ----------------
552 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
553 dnl variations of ncurses' installs.
554 dnl
555 dnl See also CF_NCURSES_HEADER, which sets the same cache variable.
556 AC_DEFUN([CF_CURSES_HEADER],[
557 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
558 cf_cv_ncurses_header=none
559 for cf_header in \
560         curses.h \
561         ncurses.h \
562         ncurses/curses.h \
563         ncurses/ncurses.h
564 do
565 AC_TRY_COMPILE([#include <${cf_header}>],
566         [initscr(); tgoto("?", 0,0)],
567         [cf_cv_ncurses_header=$cf_header; break],[])
568 done
569 ])
570
571 if test "$cf_cv_ncurses_header" = none ; then
572         AC_MSG_ERROR(No curses header-files found)
573 fi
574
575 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
576 AC_CHECK_HEADERS($cf_cv_ncurses_header)
577 ])dnl
578 dnl ---------------------------------------------------------------------------
579 dnl CF_CURSES_LIBS version: 29 updated: 2009/01/06 19:34:57
580 dnl --------------
581 dnl Look for the curses libraries.  Older curses implementations may require
582 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
583 AC_DEFUN([CF_CURSES_LIBS],[
584
585 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
586 AC_MSG_CHECKING(if we have identified curses libraries)
587 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
588     [initscr(); tgoto("?", 0,0)],
589     cf_result=yes,
590     cf_result=no)
591 AC_MSG_RESULT($cf_result)
592
593 if test "$cf_result" = no ; then
594 case $host_os in #(vi
595 freebsd*) #(vi
596     AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
597     ;;
598 hpux10.*) #(vi
599     AC_CHECK_LIB(cur_colr,initscr,[
600         LIBS="-lcur_colr $LIBS"
601         ac_cv_func_initscr=yes
602         ],[
603     AC_CHECK_LIB(Hcurses,initscr,[
604         # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
605         LIBS="-lHcurses $LIBS"
606         CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
607         ac_cv_func_initscr=yes
608         ])])
609     ;;
610 linux*) # Suse Linux does not follow /usr/lib convention
611     CF_ADD_LIBDIR(/lib)
612     ;;
613 sunos3*|sunos4*)
614     if test -d /usr/5lib ; then
615       CF_ADD_LIBDIR(/usr/5lib)
616       LIBS="$LIBS -lcurses -ltermcap"
617     fi
618     ac_cv_func_initscr=yes
619     ;;
620 esac
621
622 if test ".$ac_cv_func_initscr" != .yes ; then
623     cf_save_LIBS="$LIBS"
624     cf_term_lib=""
625     cf_curs_lib=""
626
627     if test ".${cf_cv_ncurses_version-no}" != .no
628     then
629         cf_check_list="ncurses curses cursesX"
630     else
631         cf_check_list="cursesX curses ncurses"
632     fi
633
634     # Check for library containing tgoto.  Do this before curses library
635     # because it may be needed to link the test-case for initscr.
636     AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
637         for cf_term_lib in $cf_check_list termcap termlib unknown
638         do
639             AC_CHECK_LIB($cf_term_lib,tgoto,[break])
640         done
641     ])
642
643     # Check for library containing initscr
644     test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
645         for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
646     do
647         AC_CHECK_LIB($cf_curs_lib,initscr,[break])
648     done
649     test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
650
651     LIBS="-l$cf_curs_lib $cf_save_LIBS"
652     if test "$cf_term_lib" = unknown ; then
653         AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
654         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
655             [initscr()],
656             [cf_result=yes],
657             [cf_result=no])
658         AC_MSG_RESULT($cf_result)
659         test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
660     elif test "$cf_curs_lib" = "$cf_term_lib" ; then
661         :
662     elif test "$cf_term_lib" != predefined ; then
663         AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
664         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
665             [initscr(); tgoto((char *)0, 0, 0);],
666             [cf_result=no],
667             [
668             LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
669             AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
670                 [initscr()],
671                 [cf_result=yes],
672                 [cf_result=error])
673             ])
674         AC_MSG_RESULT($cf_result)
675     fi
676 fi
677 fi
678
679 ])dnl
680 dnl ---------------------------------------------------------------------------
681 dnl CF_CURSES_TERM_H version: 6 updated: 2003/11/06 19:59:57
682 dnl ----------------
683 dnl SVr4 curses should have term.h as well (where it puts the definitions of
684 dnl the low-level interface).  This may not be true in old/broken implementations,
685 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
686 dnl running with Solaris 2.5.1).
687 AC_DEFUN([CF_CURSES_TERM_H],
688 [
689 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
690
691 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
692 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
693 # for <term.h> if we do not find the variant.
694 for cf_header in \
695         `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
696         term.h
697 do
698         AC_TRY_COMPILE([
699 #include <${cf_cv_ncurses_header-curses.h}>
700 #include <${cf_header}>],
701         [WINDOW *x],
702         [cf_cv_term_header=$cf_header
703          break],
704         [cf_cv_term_header=no])
705 done
706 ])
707
708 case $cf_cv_term_header in #(vi
709 term.h) #(vi
710         AC_DEFINE(HAVE_TERM_H)
711         ;;
712 ncurses/term.h)
713         AC_DEFINE(HAVE_NCURSES_TERM_H)
714         ;;
715 ncursesw/term.h)
716         AC_DEFINE(HAVE_NCURSESW_TERM_H)
717         ;;
718 esac
719 ])dnl
720 dnl ---------------------------------------------------------------------------
721 dnl CF_CURSES_WACS_MAP version: 3 updated: 2003/05/17 22:19:02
722 dnl ------------------
723 dnl Check for likely values of wacs_map[]:
724 AC_DEFUN([CF_CURSES_WACS_MAP],
725 [
726 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
727         cf_cv_curses_wacs_map=unknown
728         for name in wacs_map _wacs_map __wacs_map _nc_wacs
729         do
730         AC_TRY_LINK([
731 #ifndef _XOPEN_SOURCE_EXTENDED
732 #define _XOPEN_SOURCE_EXTENDED
733 #endif
734 #include <${cf_cv_ncurses_header-curses.h}>],
735         [$name['k'] = *WACS_PLUS],
736         [cf_cv_curses_wacs_map=$name
737          break])
738         done])
739 ])
740 dnl ---------------------------------------------------------------------------
741 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
742 dnl ----------
743 dnl "dirname" is not portable, so we fake it with a shell script.
744 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
745 dnl ---------------------------------------------------------------------------
746 dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11
747 dnl ---------------
748 dnl You can always use "make -n" to see the actual options, but it's hard to
749 dnl pick out/analyze warning messages when the compile-line is long.
750 dnl
751 dnl Sets:
752 dnl     ECHO_LT - symbol to control if libtool is verbose
753 dnl     ECHO_LD - symbol to prefix "cc -o" lines
754 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
755 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
756 dnl     ECHO_CC - symbol to put before any "cc" line
757 dnl
758 AC_DEFUN([CF_DISABLE_ECHO],[
759 AC_MSG_CHECKING(if you want to see long compiling messages)
760 CF_ARG_DISABLE(echo,
761         [  --disable-echo          display "compiling" commands],
762         [
763     ECHO_LT='--silent'
764     ECHO_LD='@echo linking [$]@;'
765     RULE_CC='   @echo compiling [$]<'
766     SHOW_CC='   @echo compiling [$]@'
767     ECHO_CC='@'
768 ],[
769     ECHO_LT=''
770     ECHO_LD=''
771     RULE_CC='# compiling'
772     SHOW_CC='# compiling'
773     ECHO_CC=''
774 ])
775 AC_MSG_RESULT($enableval)
776 AC_SUBST(ECHO_LT)
777 AC_SUBST(ECHO_LD)
778 AC_SUBST(RULE_CC)
779 AC_SUBST(SHOW_CC)
780 AC_SUBST(ECHO_CC)
781 ])dnl
782 dnl ---------------------------------------------------------------------------
783 dnl CF_ENABLE_WARNINGS version: 3 updated: 2003/05/24 14:24:29
784 dnl ------------------
785 dnl Configure-option to enable gcc warnings
786 AC_DEFUN([CF_ENABLE_WARNINGS],[
787 if ( test "$GCC" = yes || test "$GXX" = yes )
788 then
789 AC_MSG_CHECKING(if you want to turn on gcc warnings)
790 CF_ARG_ENABLE(warnings,
791         [  --enable-warnings       test: turn on gcc compiler warnings],
792         [with_warnings=yes],
793         [with_warnings=no])
794 AC_MSG_RESULT($with_warnings)
795 if test "$with_warnings" = "yes"
796 then
797         CF_GCC_WARNINGS
798 fi
799 fi
800 ])dnl
801 dnl ---------------------------------------------------------------------------
802 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
803 dnl ---------------
804 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
805 dnl prefer a standard location, and use -L options only if we do not find the
806 dnl library in the standard library location(s).
807 dnl     $1 = library name
808 dnl     $2 = library class, usually the same as library name
809 dnl     $3 = includes
810 dnl     $4 = code fragment to compile/link
811 dnl     $5 = corresponding function-name
812 dnl     $6 = flag, nonnull if failure should not cause an error-exit
813 dnl
814 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
815 dnl to use a -L option.
816 AC_DEFUN([CF_FIND_LIBRARY],
817 [
818         eval 'cf_cv_have_lib_'$1'=no'
819         cf_libdir=""
820         AC_CHECK_FUNC($5,
821                 eval 'cf_cv_have_lib_'$1'=yes',[
822                 cf_save_LIBS="$LIBS"
823                 AC_MSG_CHECKING(for $5 in -l$1)
824                 LIBS="-l$1 $LIBS"
825                 AC_TRY_LINK([$3],[$4],
826                         [AC_MSG_RESULT(yes)
827                          eval 'cf_cv_have_lib_'$1'=yes'
828                         ],
829                         [AC_MSG_RESULT(no)
830                         CF_LIBRARY_PATH(cf_search,$2)
831                         for cf_libdir in $cf_search
832                         do
833                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
834                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
835                                 AC_TRY_LINK([$3],[$4],
836                                         [AC_MSG_RESULT(yes)
837                                          eval 'cf_cv_have_lib_'$1'=yes'
838                                          break],
839                                         [AC_MSG_RESULT(no)
840                                          LIBS="$cf_save_LIBS"])
841                         done
842                         ])
843                 ])
844 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
845 ifelse($6,,[
846 if test $cf_found_library = no ; then
847         AC_MSG_ERROR(Cannot link $1 library)
848 fi
849 ])
850 ])dnl
851 dnl ---------------------------------------------------------------------------
852 dnl CF_FIND_LINKAGE version: 13 updated: 2008/12/24 07:59:55
853 dnl ---------------
854 dnl Find a library (specifically the linkage used in the code fragment),
855 dnl searching for it if it is not already in the library path.
856 dnl See also CF_ADD_SEARCHPATH.
857 dnl
858 dnl Parameters (4-on are optional):
859 dnl     $1 = headers for library entrypoint
860 dnl     $2 = code fragment for library entrypoint
861 dnl     $3 = the library name without the "-l" option or ".so" suffix.
862 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
863 dnl     $5 = action to perform if not successful
864 dnl     $6 = module name, if not the same as the library name
865 dnl     $7 = extra libraries
866 dnl
867 dnl Sets these variables:
868 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
869 dnl     $cf_cv_header_path_$3 - include-directory if needed
870 dnl     $cf_cv_library_path_$3 - library-directory if needed
871 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
872 AC_DEFUN([CF_FIND_LINKAGE],[
873
874 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
875 # will be set on completion of the AC_TRY_LINK below.
876 cf_cv_header_path_$3=
877 cf_cv_library_path_$3=
878
879 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
880
881 AC_TRY_LINK([$1],[$2],
882     cf_cv_find_linkage_$3=yes,[
883     cf_cv_find_linkage_$3=no
884
885     CF_VERBOSE(find linkage for $3 library)
886     CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
887
888     cf_save_CPPFLAGS="$CPPFLAGS"
889     cf_test_CPPFLAGS="$CPPFLAGS"
890
891     CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
892     for cf_cv_header_path_$3 in $cf_search
893     do
894       if test -d $cf_cv_header_path_$3 ; then
895         CF_VERBOSE(... testing $cf_cv_header_path_$3)
896         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
897         AC_TRY_COMPILE([$1],[$2],[
898             CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
899             cf_cv_find_linkage_$3=maybe
900             cf_test_CPPFLAGS="$CPPFLAGS"
901             break],[
902             CPPFLAGS="$cf_save_CPPFLAGS"
903             ])
904       fi
905     done
906
907     if test "$cf_cv_find_linkage_$3" = maybe ; then
908
909       CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
910
911       cf_save_LIBS="$LIBS"
912       cf_save_LDFLAGS="$LDFLAGS"
913
914       ifelse([$6],,,[
915         CPPFLAGS="$cf_test_CPPFLAGS"
916         LIBS="-l$3 $7 $cf_save_LIBS"
917         AC_TRY_LINK([$1],[$2],[
918             CF_VERBOSE(... found $3 library in system)
919             cf_cv_find_linkage_$3=yes])
920             CPPFLAGS="$cf_save_CPPFLAGS"
921             LIBS="$cf_save_LIBS"
922             ])
923
924       if test "$cf_cv_find_linkage_$3" != yes ; then
925         CF_LIBRARY_PATH(cf_search,$3)
926         for cf_cv_library_path_$3 in $cf_search
927         do
928           if test -d $cf_cv_library_path_$3 ; then
929             CF_VERBOSE(... testing $cf_cv_library_path_$3)
930             CPPFLAGS="$cf_test_CPPFLAGS"
931             LIBS="-l$3 $7 $cf_save_LIBS"
932             LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
933             AC_TRY_LINK([$1],[$2],[
934                 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
935                 cf_cv_find_linkage_$3=yes
936                 cf_cv_library_file_$3="-l$3"
937                 break],[
938                 CPPFLAGS="$cf_save_CPPFLAGS"
939                 LIBS="$cf_save_LIBS"
940                 LDFLAGS="$cf_save_LDFLAGS"
941                 ])
942           fi
943         done
944         LIBS="$cf_save_LIBS"
945         CPPFLAGS="$cf_save_CPPFLAGS"
946         LDFLAGS="$cf_save_LDFLAGS"
947       fi
948
949     else
950       cf_cv_find_linkage_$3=no
951     fi
952     ],$7)
953
954 if test "$cf_cv_find_linkage_$3" = yes ; then
955 ifelse([$4],,[
956   CF_ADD_INCDIR($cf_cv_header_path_$3)
957   CF_ADD_LIBDIR($cf_cv_library_path_$3)
958   LIBS="-l$3 $LIBS"
959 ],[$4])
960 else
961 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
962 fi
963 ])dnl
964 dnl ---------------------------------------------------------------------------
965 dnl CF_FUNC_CURSES_VERSION version: 4 updated: 2007/04/28 09:15:55
966 dnl ----------------------
967 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
968 dnl It's a character string "SVR4", not documented.
969 AC_DEFUN([CF_FUNC_CURSES_VERSION],
970 [
971 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
972 AC_TRY_RUN([
973 #include <${cf_cv_ncurses_header-curses.h}>
974 int main()
975 {
976         char temp[1024];
977         sprintf(temp, "%s\n", curses_version());
978         ${cf_cv_main_return-return}(0);
979 }]
980 ,[cf_cv_func_curses_version=yes]
981 ,[cf_cv_func_curses_version=no]
982 ,[cf_cv_func_curses_version=unknown])
983 rm -f core])
984 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
985 ])
986 dnl ---------------------------------------------------------------------------
987 dnl CF_GCC_ATTRIBUTES version: 11 updated: 2007/07/29 09:55:12
988 dnl -----------------
989 dnl Test for availability of useful gcc __attribute__ directives to quiet
990 dnl compiler warnings.  Though useful, not all are supported -- and contrary
991 dnl to documentation, unrecognized directives cause older compilers to barf.
992 AC_DEFUN([CF_GCC_ATTRIBUTES],
993 [
994 if test "$GCC" = yes
995 then
996 cat > conftest.i <<EOF
997 #ifndef GCC_PRINTF
998 #define GCC_PRINTF 0
999 #endif
1000 #ifndef GCC_SCANF
1001 #define GCC_SCANF 0
1002 #endif
1003 #ifndef GCC_NORETURN
1004 #define GCC_NORETURN /* nothing */
1005 #endif
1006 #ifndef GCC_UNUSED
1007 #define GCC_UNUSED /* nothing */
1008 #endif
1009 EOF
1010 if test "$GCC" = yes
1011 then
1012         AC_CHECKING([for $CC __attribute__ directives])
1013 cat > conftest.$ac_ext <<EOF
1014 #line __oline__ "${as_me-configure}"
1015 #include "confdefs.h"
1016 #include "conftest.h"
1017 #include "conftest.i"
1018 #if     GCC_PRINTF
1019 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1020 #else
1021 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1022 #endif
1023 #if     GCC_SCANF
1024 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1025 #else
1026 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1027 #endif
1028 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1029 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1030 extern void foo(void) GCC_NORETURN;
1031 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1032 EOF
1033         for cf_attribute in scanf printf unused noreturn
1034         do
1035                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1036                 cf_directive="__attribute__(($cf_attribute))"
1037                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1038                 case $cf_attribute in
1039                 scanf|printf)
1040                 cat >conftest.h <<EOF
1041 #define GCC_$cf_ATTRIBUTE 1
1042 EOF
1043                         ;;
1044                 *)
1045                 cat >conftest.h <<EOF
1046 #define GCC_$cf_ATTRIBUTE $cf_directive
1047 EOF
1048                         ;;
1049                 esac
1050                 if AC_TRY_EVAL(ac_compile); then
1051                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1052                         cat conftest.h >>confdefs.h
1053                 fi
1054         done
1055 else
1056         fgrep define conftest.i >>confdefs.h
1057 fi
1058 rm -rf conftest*
1059 fi
1060 ])dnl
1061 dnl ---------------------------------------------------------------------------
1062 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
1063 dnl --------------
1064 dnl Find version of gcc
1065 AC_DEFUN([CF_GCC_VERSION],[
1066 AC_REQUIRE([AC_PROG_CC])
1067 GCC_VERSION=none
1068 if test "$GCC" = yes ; then
1069         AC_MSG_CHECKING(version of $CC)
1070         GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1071         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1072         AC_MSG_RESULT($GCC_VERSION)
1073 fi
1074 ])dnl
1075 dnl ---------------------------------------------------------------------------
1076 dnl CF_GCC_WARNINGS version: 24 updated: 2009/02/01 15:21:00
1077 dnl ---------------
1078 dnl Check if the compiler supports useful warning options.  There's a few that
1079 dnl we don't use, simply because they're too noisy:
1080 dnl
1081 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1082 dnl     -Wredundant-decls (system headers make this too noisy)
1083 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1084 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1085 dnl             is enabled for ncurses using "--enable-const".
1086 dnl     -pedantic
1087 dnl
1088 dnl Parameter:
1089 dnl     $1 is an optional list of gcc warning flags that a particular
1090 dnl             application might want to use, e.g., "no-unused" for
1091 dnl             -Wno-unused
1092 dnl Special:
1093 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1094 dnl
1095 AC_DEFUN([CF_GCC_WARNINGS],
1096 [
1097 AC_REQUIRE([CF_GCC_VERSION])
1098 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1099
1100 cat > conftest.$ac_ext <<EOF
1101 #line __oline__ "${as_me-configure}"
1102 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1103 EOF
1104
1105 if test "$INTEL_COMPILER" = yes
1106 then
1107 # The "-wdXXX" options suppress warnings:
1108 # remark #1419: external declaration in primary source file
1109 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1110 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1111 # remark #193: zero used for undefined preprocessing identifier
1112 # remark #593: variable "curs_sb_left_arrow" was set but never used
1113 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1114 # remark #869: parameter "tw" was never referenced
1115 # remark #981: operands are evaluated in unspecified order
1116 # warning #279: controlling expression is constant
1117
1118         AC_CHECKING([for $CC warning options])
1119         cf_save_CFLAGS="$CFLAGS"
1120         EXTRA_CFLAGS="-Wall"
1121         for cf_opt in \
1122                 wd1419 \
1123                 wd1683 \
1124                 wd1684 \
1125                 wd193 \
1126                 wd593 \
1127                 wd279 \
1128                 wd810 \
1129                 wd869 \
1130                 wd981
1131         do
1132                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1133                 if AC_TRY_EVAL(ac_compile); then
1134                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1135                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1136                 fi
1137         done
1138         CFLAGS="$cf_save_CFLAGS"
1139
1140 elif test "$GCC" = yes
1141 then
1142         AC_CHECKING([for $CC warning options])
1143         cf_save_CFLAGS="$CFLAGS"
1144         EXTRA_CFLAGS="-W -Wall"
1145         cf_warn_CONST=""
1146         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1147         for cf_opt in \
1148                 Wbad-function-cast \
1149                 Wcast-align \
1150                 Wcast-qual \
1151                 Winline \
1152                 Wmissing-declarations \
1153                 Wmissing-prototypes \
1154                 Wnested-externs \
1155                 Wpointer-arith \
1156                 Wshadow \
1157                 Wstrict-prototypes \
1158                 Wundef $cf_warn_CONST $1
1159         do
1160                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1161                 if AC_TRY_EVAL(ac_compile); then
1162                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1163                         case $cf_opt in #(vi
1164                         Wcast-qual) #(vi
1165                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1166                                 ;;
1167                         Winline) #(vi
1168                                 case $GCC_VERSION in
1169                                 [[34]].*)
1170                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1171                                         continue;;
1172                                 esac
1173                                 ;;
1174                         esac
1175                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1176                 fi
1177         done
1178         CFLAGS="$cf_save_CFLAGS"
1179 fi
1180 rm -f conftest*
1181
1182 AC_SUBST(EXTRA_CFLAGS)
1183 ])dnl
1184 dnl ---------------------------------------------------------------------------
1185 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1186 dnl -------------
1187 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1188 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1189 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1190 dnl since it is interwoven with GNU extensions.
1191 dnl
1192 dnl Well, yes we could work around it...
1193 AC_DEFUN([CF_GNU_SOURCE],
1194 [
1195 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1196 AC_TRY_COMPILE([#include <sys/types.h>],[
1197 #ifndef _XOPEN_SOURCE
1198 make an error
1199 #endif],
1200         [cf_cv_gnu_source=no],
1201         [cf_save="$CPPFLAGS"
1202          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1203          AC_TRY_COMPILE([#include <sys/types.h>],[
1204 #ifdef _XOPEN_SOURCE
1205 make an error
1206 #endif],
1207         [cf_cv_gnu_source=no],
1208         [cf_cv_gnu_source=yes])
1209         CPPFLAGS="$cf_save"
1210         ])
1211 ])
1212 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1213 ])dnl
1214 dnl ---------------------------------------------------------------------------
1215 dnl CF_HEADER_PATH version: 9 updated: 2008/12/07 19:38:31
1216 dnl --------------
1217 dnl Construct a search-list of directories for a nonstandard header-file
1218 dnl
1219 dnl Parameters
1220 dnl     $1 = the variable to return as result
1221 dnl     $2 = the package name
1222 AC_DEFUN([CF_HEADER_PATH],
1223 [
1224 cf_header_path_list=""
1225 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1226         for cf_header_path in $CPPFLAGS $CFLAGS
1227         do
1228                 case $cf_header_path in #(vi
1229                 -I*)
1230                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1231                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1232                         cf_header_path_list="$cf_header_path_list [$]$1"
1233                         ;;
1234                 esac
1235         done
1236 fi
1237
1238 CF_SUBDIR_PATH($1,$2,include)
1239
1240 test "$includedir" != NONE && \
1241 test "$includedir" != "/usr/include" && \
1242 test -d "$includedir" && {
1243         test -d $includedir &&    $1="[$]$1 $includedir"
1244         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1245 }
1246
1247 test "$oldincludedir" != NONE && \
1248 test "$oldincludedir" != "/usr/include" && \
1249 test -d "$oldincludedir" && {
1250         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1251         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1252 }
1253
1254 $1="$cf_header_path_list [$]$1"
1255 ])dnl
1256 dnl ---------------------------------------------------------------------------
1257 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
1258 dnl -----------------
1259 dnl If we do not have a given script, look for it in the parent directory.
1260 AC_DEFUN([CF_INHERIT_SCRIPT],
1261 [
1262 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1263 ])dnl
1264 dnl ---------------------------------------------------------------------------
1265 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
1266 dnl -----------------
1267 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1268 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1269 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1270 dnl
1271 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1272 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1273 dnl the wrappers for gcc and g++ warnings.
1274 dnl
1275 dnl $1 = GCC (default) or GXX
1276 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1277 dnl $3 = CFLAGS (default) or CXXFLAGS
1278 AC_DEFUN([CF_INTEL_COMPILER],[
1279 ifelse($2,,INTEL_COMPILER,[$2])=no
1280
1281 if test "$ifelse($1,,[$1],GCC)" = yes ; then
1282         case $host_os in
1283         linux*|gnu*)
1284                 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
1285                 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
1286                 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
1287                 AC_TRY_COMPILE([],[
1288 #ifdef __INTEL_COMPILER
1289 #else
1290 make an error
1291 #endif
1292 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
1293 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1294 ],[])
1295                 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
1296                 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
1297                 ;;
1298         esac
1299 fi
1300 ])dnl
1301 dnl ---------------------------------------------------------------------------
1302 dnl CF_LIBRARY_PATH version: 8 updated: 2008/12/07 19:38:31
1303 dnl ---------------
1304 dnl Construct a search-list of directories for a nonstandard library-file
1305 dnl
1306 dnl Parameters
1307 dnl     $1 = the variable to return as result
1308 dnl     $2 = the package name
1309 AC_DEFUN([CF_LIBRARY_PATH],
1310 [
1311 cf_library_path_list=""
1312 if test -n "${LDFLAGS}${LIBS}" ; then
1313         for cf_library_path in $LDFLAGS $LIBS
1314         do
1315                 case $cf_library_path in #(vi
1316                 -L*)
1317                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1318                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1319                         cf_library_path_list="$cf_library_path_list [$]$1"
1320                         ;;
1321                 esac
1322         done
1323 fi
1324
1325 CF_SUBDIR_PATH($1,$2,lib)
1326
1327 $1="$cf_library_path_list [$]$1"
1328 ])dnl
1329 dnl ---------------------------------------------------------------------------
1330 dnl CF_MIN_GETCCHAR version: 2 updated: 2009/07/16 21:03:10
1331 dnl ---------------
1332 dnl CF_MIN_GETCCHAR
1333 dnl Check whether getcchar's return value counts the trailing null in a wchar_t
1334 dnl string, or not.  X/Open says it does, but Tru64 and Solaris do not do this.
1335 AC_DEFUN([CF_MIN_GETCCHAR],[
1336 AC_CACHE_CHECK(if getcchar counts trailing null,cf_cv_min_getcchar,[
1337 AC_TRY_RUN([
1338 #include <stdlib.h>
1339 #include <stdarg.h>
1340 #include <${cf_cv_ncurses_header-curses.h}>
1341
1342 int main()
1343 {
1344         wchar_t data[2];
1345         cchar_t temp[2];
1346         int count;
1347         data[0] = L'\0';
1348     setcchar(temp, data, 0, 0, (void *)0);
1349         count = getcchar(temp, (wchar_t *)0, (attr_t *)0, (short *)0, (void *)0);
1350         ${cf_cv_main_return-return}(count != 0);
1351 }],
1352         [cf_cv_min_getcchar=no],
1353         [cf_cv_min_getcchar=yes],
1354         [cf_cv_min_getcchar=yes])
1355 ])
1356 if test "$cf_cv_min_getcchar" = yes ; then
1357         AC_DEFINE(MIN_GETCCHAR,1)
1358 fi
1359 ])dnl
1360 dnl ---------------------------------------------------------------------------
1361 dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
1362 dnl ----------
1363 dnl Write a debug message to config.log, along with the line number in the
1364 dnl configure script.
1365 AC_DEFUN([CF_MSG_LOG],[
1366 echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1367 ])dnl
1368 dnl ---------------------------------------------------------------------------
1369 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1370 dnl -------------------
1371 dnl Check if we can compile with ncurses' header file
1372 dnl $1 is the cache variable to set
1373 dnl $2 is the header-file to include
1374 dnl $3 is the root name (ncurses or ncursesw)
1375 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1376         AC_TRY_COMPILE([
1377 ]ifelse($3,ncursesw,[
1378 #define _XOPEN_SOURCE_EXTENDED
1379 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
1380 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
1381 ])[
1382 #include <$2>],[
1383 #ifdef NCURSES_VERSION
1384 ]ifelse($3,ncursesw,[
1385 #ifndef WACS_BSSB
1386         make an error
1387 #endif
1388 ])[
1389 printf("%s\n", NCURSES_VERSION);
1390 #else
1391 #ifdef __NCURSES_H
1392 printf("old\n");
1393 #else
1394         make an error
1395 #endif
1396 #endif
1397         ]
1398         ,[$1=$2]
1399         ,[$1=no])
1400 ])dnl
1401 dnl ---------------------------------------------------------------------------
1402 dnl CF_NCURSES_CONFIG version: 5 updated: 2009/01/11 15:31:22
1403 dnl -----------------
1404 dnl Tie together the configure-script macros for ncurses.
1405 dnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
1406 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
1407 dnl
1408 dnl $1 is the root library name (default: "ncurses")
1409 AC_DEFUN([CF_NCURSES_CONFIG],
1410 [
1411 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1412
1413 echo "Looking for ${cf_ncuconfig_root}-config"
1414 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
1415
1416 if test "$NCURSES_CONFIG" != none ; then
1417
1418 cf_cv_ncurses_header=curses.h
1419
1420 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1421 LIBS="`$NCURSES_CONFIG --libs` $LIBS"
1422
1423 dnl like CF_NCURSES_CPPFLAGS
1424 AC_DEFINE(NCURSES)
1425
1426 dnl like CF_NCURSES_LIBS
1427 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1428 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1429
1430 dnl like CF_NCURSES_VERSION
1431 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1432
1433 else
1434
1435 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1436 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1437
1438 fi
1439 ])dnl
1440 dnl ---------------------------------------------------------------------------
1441 dnl CF_NCURSES_CPPFLAGS version: 19 updated: 2007/07/29 13:35:20
1442 dnl -------------------
1443 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1444 dnl the CPPFLAGS variable so we can include its header.
1445 dnl
1446 dnl The header files may be installed as either curses.h, or ncurses.h (would
1447 dnl be obsolete, except that some packagers prefer this name to distinguish it
1448 dnl from a "native" curses implementation).  If not installed for overwrite,
1449 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1450 dnl /usr/include/ncurses), but someone may have installed overwriting the
1451 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
1452 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1453 dnl the header.
1454 dnl
1455 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1456 dnl is already in the include-path, don't even bother with this, since we cannot
1457 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
1458 dnl
1459 dnl The optional parameter gives the root name of the library, in case it is
1460 dnl not installed as the default curses library.  That is how the
1461 dnl wide-character version of ncurses is installed.
1462 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1463 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1464
1465 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1466 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1467
1468 test -n "$cf_cv_curses_dir" && \
1469 test "$cf_cv_curses_dir" != "no" && { \
1470   CF_ADD_INCDIR($cf_cv_curses_dir/include $cf_cv_curses_dir/include/$cf_ncuhdr_root)
1471 }
1472
1473 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1474         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1475         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1476         for cf_header in $cf_header_list
1477         do
1478                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1479                 test "$cf_cv_ncurses_h" != no && break
1480         done
1481 ])
1482
1483 CF_NCURSES_HEADER
1484 CF_TERM_HEADER
1485
1486 # some applications need this, but should check for NCURSES_VERSION
1487 AC_DEFINE(NCURSES)
1488
1489 CF_NCURSES_VERSION
1490 ])dnl
1491 dnl ---------------------------------------------------------------------------
1492 dnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
1493 dnl -----------------
1494 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1495 dnl variations of ncurses' installs.
1496 dnl
1497 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1498 AC_DEFUN([CF_NCURSES_HEADER],[
1499
1500 if test "$cf_cv_ncurses_h" != no ; then
1501         cf_cv_ncurses_header=$cf_cv_ncurses_h
1502 else
1503
1504 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1505         test -n "$verbose" && echo
1506         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1507         test -n "$verbose" && echo search path $cf_search
1508         cf_save2_CPPFLAGS="$CPPFLAGS"
1509         for cf_incdir in $cf_search
1510         do
1511                 CF_ADD_INCDIR($cf_incdir)
1512                 for cf_header in \
1513                         ncurses.h \
1514                         curses.h
1515                 do
1516                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1517                         if test "$cf_cv_ncurses_h2" != no ; then
1518                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1519                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
1520                                 break
1521                         fi
1522                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1523                 done
1524                 CPPFLAGS="$cf_save2_CPPFLAGS"
1525                 test "$cf_cv_ncurses_h2" != no && break
1526         done
1527         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
1528         ])
1529
1530         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1531         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1532         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1533                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1534         fi
1535         CF_ADD_INCDIR($cf_1st_incdir)
1536
1537 fi
1538
1539 # Set definitions to allow ifdef'ing for ncurses.h
1540
1541 case $cf_cv_ncurses_header in # (vi
1542 *ncurses.h)
1543         AC_DEFINE(HAVE_NCURSES_H)
1544         ;;
1545 esac
1546
1547 case $cf_cv_ncurses_header in # (vi
1548 ncurses/curses.h|ncurses/ncurses.h)
1549         AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1550         ;;
1551 ncursesw/curses.h|ncursesw/ncurses.h)
1552         AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1553         ;;
1554 esac
1555
1556 ])dnl
1557 dnl ---------------------------------------------------------------------------
1558 dnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
1559 dnl ---------------
1560 dnl Look for the ncurses library.  This is a little complicated on Linux,
1561 dnl because it may be linked with the gpm (general purpose mouse) library.
1562 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1563 dnl unusable with ncurses.  However, we don't want to link with gpm unless
1564 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1565 dnl and the linker will record a dependency.
1566 dnl
1567 dnl The optional parameter gives the root name of the library, in case it is
1568 dnl not installed as the default curses library.  That is how the
1569 dnl wide-character version of ncurses is installed.
1570 AC_DEFUN([CF_NCURSES_LIBS],
1571 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1572
1573 cf_nculib_root=ifelse($1,,ncurses,$1)
1574         # This works, except for the special case where we find gpm, but
1575         # ncurses is in a nonstandard location via $LIBS, and we really want
1576         # to link gpm.
1577 cf_ncurses_LIBS=""
1578 cf_ncurses_SAVE="$LIBS"
1579 AC_CHECK_LIB(gpm,Gpm_Open,
1580         [AC_CHECK_LIB(gpm,initscr,
1581                 [LIBS="$cf_ncurses_SAVE"],
1582                 [cf_ncurses_LIBS="-lgpm"])])
1583
1584 case $host_os in #(vi
1585 freebsd*)
1586         # This is only necessary if you are linking against an obsolete
1587         # version of ncurses (but it should do no harm, since it's static).
1588         if test "$cf_nculib_root" = ncurses ; then
1589                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1590         fi
1591         ;;
1592 esac
1593
1594 LIBS="$cf_ncurses_LIBS $LIBS"
1595
1596 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1597 then
1598         CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
1599         LIBS="-l$cf_nculib_root $LIBS"
1600 else
1601         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1602                 [#include <${cf_cv_ncurses_header-curses.h}>],
1603                 [initscr()],
1604                 initscr)
1605 fi
1606
1607 if test -n "$cf_ncurses_LIBS" ; then
1608         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1609         cf_ncurses_SAVE="$LIBS"
1610         for p in $cf_ncurses_LIBS ; do
1611                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1612                 if test "$q" != "$LIBS" ; then
1613                         LIBS="$q"
1614                 fi
1615         done
1616         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1617                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1618                 [AC_MSG_RESULT(yes)],
1619                 [AC_MSG_RESULT(no)
1620                  LIBS="$cf_ncurses_SAVE"])
1621 fi
1622
1623 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1624 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1625 ])dnl
1626 dnl ---------------------------------------------------------------------------
1627 dnl CF_NCURSES_VERSION version: 12 updated: 2007/04/28 09:15:55
1628 dnl ------------------
1629 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1630 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
1631 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1632 AC_DEFUN([CF_NCURSES_VERSION],
1633 [
1634 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1635 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1636         cf_cv_ncurses_version=no
1637         cf_tempfile=out$$
1638         rm -f $cf_tempfile
1639         AC_TRY_RUN([
1640 #include <${cf_cv_ncurses_header-curses.h}>
1641 #include <stdio.h>
1642 int main()
1643 {
1644         FILE *fp = fopen("$cf_tempfile", "w");
1645 #ifdef NCURSES_VERSION
1646 # ifdef NCURSES_VERSION_PATCH
1647         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1648 # else
1649         fprintf(fp, "%s\n", NCURSES_VERSION);
1650 # endif
1651 #else
1652 # ifdef __NCURSES_H
1653         fprintf(fp, "old\n");
1654 # else
1655         make an error
1656 # endif
1657 #endif
1658         ${cf_cv_main_return-return}(0);
1659 }],[
1660         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1661
1662         # This will not work if the preprocessor splits the line after the
1663         # Autoconf token.  The 'unproto' program does that.
1664         cat > conftest.$ac_ext <<EOF
1665 #include <${cf_cv_ncurses_header-curses.h}>
1666 #undef Autoconf
1667 #ifdef NCURSES_VERSION
1668 Autoconf NCURSES_VERSION
1669 #else
1670 #ifdef __NCURSES_H
1671 Autoconf "old"
1672 #endif
1673 ;
1674 #endif
1675 EOF
1676         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1677         AC_TRY_EVAL(cf_try)
1678         if test -f conftest.out ; then
1679                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1680                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1681                 rm -f conftest.out
1682         fi
1683 ])
1684         rm -f $cf_tempfile
1685 ])
1686 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1687 ])dnl
1688 dnl ---------------------------------------------------------------------------
1689 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
1690 dnl ----------------------
1691 dnl Check for ncurses "wrap-prefix" used for public variables which have been
1692 dnl wrapped with a function to help with concurrency control.
1693 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
1694 [
1695 AC_MSG_CHECKING(for ncurses wrap-prefix)
1696 AC_ARG_WITH(ncurses-wrap-prefix,
1697         [  --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
1698         [NCURSES_WRAP_PREFIX=$withval],
1699         [NCURSES_WRAP_PREFIX=_nc_])
1700 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
1701
1702 AC_SUBST(NCURSES_WRAP_PREFIX)
1703 ])
1704 dnl ---------------------------------------------------------------------------
1705 dnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
1706 dnl --------------
1707 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1708 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1709 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1710 dnl delayed evaluation of those symbols.
1711 AC_DEFUN([CF_PATH_SYNTAX],[
1712 if test "x$prefix" != xNONE; then
1713   cf_path_syntax="$prefix"
1714 else
1715   cf_path_syntax="$ac_default_prefix"
1716 fi
1717
1718 case ".[$]$1" in #(vi
1719 .\[$]\(*\)*|.\'*\'*) #(vi
1720   ;;
1721 ..|./*|.\\*) #(vi
1722   ;;
1723 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1724   ;;
1725 .\[$]{*prefix}*) #(vi
1726   eval $1="[$]$1"
1727   case ".[$]$1" in #(vi
1728   .NONE/*)
1729     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1730     ;;
1731   esac
1732   ;; #(vi
1733 .no|.NONE/*)
1734   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1735   ;;
1736 *)
1737   ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1738   ;;
1739 esac
1740 ])dnl
1741 dnl ---------------------------------------------------------------------------
1742 dnl CF_PDCURSES_X11 version: 9 updated: 2009/01/11 15:31:37
1743 dnl ---------------
1744 dnl Configure for PDCurses' X11 library
1745 AC_DEFUN([CF_PDCURSES_X11],[
1746 AC_REQUIRE([CF_X_ATHENA])
1747
1748 AC_PATH_PROGS(XCURSES_CONFIG,xcurses-config,none)
1749
1750 if test "$XCURSES_CONFIG" != none ; then
1751
1752 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
1753 LIBS="`$XCURSES_CONFIG --libs` $LIBS"
1754
1755 cf_cv_lib_XCurses=yes
1756
1757 else
1758
1759 LDFLAGS="$LDFLAGS $X_LIBS"
1760 CF_CHECK_CFLAGS($X_CFLAGS)
1761 AC_CHECK_LIB(X11,XOpenDisplay,
1762         [LIBS="-lX11 $LIBS"],,
1763         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
1764 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
1765 LIBS="-lXCurses $LIBS"
1766 AC_TRY_LINK([
1767 #include <xcurses.h>
1768 char *XCursesProgramName = "test";
1769 ],[XCursesExit();],
1770 [cf_cv_lib_XCurses=yes],
1771 [cf_cv_lib_XCurses=no])
1772 ])
1773
1774 fi
1775
1776 if test $cf_cv_lib_XCurses = yes ; then
1777         AC_DEFINE(UNIX)
1778         AC_DEFINE(XCURSES)
1779         AC_DEFINE(HAVE_XCURSES)
1780 else
1781         AC_MSG_ERROR(Cannot link with XCurses)
1782 fi
1783 ])dnl
1784 dnl ---------------------------------------------------------------------------
1785 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1786 dnl -----------------
1787 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1788 dnl
1789 dnl     POSIX.1-1990                            _POSIX_SOURCE
1790 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
1791 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
1792 dnl             Bindings Option
1793 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
1794 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
1795 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
1796 dnl
1797 dnl Parameters:
1798 dnl     $1 is the nominal value for _POSIX_C_SOURCE
1799 AC_DEFUN([CF_POSIX_C_SOURCE],
1800 [
1801 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1802
1803 cf_save_CFLAGS="$CFLAGS"
1804 cf_save_CPPFLAGS="$CPPFLAGS"
1805
1806 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1807 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1808
1809 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1810         CF_MSG_LOG(if the symbol is already defined go no further)
1811         AC_TRY_COMPILE([#include <sys/types.h>],[
1812 #ifndef _POSIX_C_SOURCE
1813 make an error
1814 #endif],
1815         [cf_cv_posix_c_source=no],
1816         [cf_want_posix_source=no
1817          case .$cf_POSIX_C_SOURCE in #(vi
1818          .[[12]]??*) #(vi
1819                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1820                 ;;
1821          .2) #(vi
1822                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1823                 cf_want_posix_source=yes
1824                 ;;
1825          .*)
1826                 cf_want_posix_source=yes
1827                 ;;
1828          esac
1829          if test "$cf_want_posix_source" = yes ; then
1830                 AC_TRY_COMPILE([#include <sys/types.h>],[
1831 #ifdef _POSIX_SOURCE
1832 make an error
1833 #endif],[],
1834                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1835          fi
1836          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1837          CFLAGS="$cf_trim_CFLAGS"
1838          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1839          CF_MSG_LOG(if the second compile does not leave our definition intact error)
1840          AC_TRY_COMPILE([#include <sys/types.h>],[
1841 #ifndef _POSIX_C_SOURCE
1842 make an error
1843 #endif],,
1844          [cf_cv_posix_c_source=no])
1845          CFLAGS="$cf_save_CFLAGS"
1846          CPPFLAGS="$cf_save_CPPFLAGS"
1847         ])
1848 ])
1849
1850 if test "$cf_cv_posix_c_source" != no ; then
1851         CFLAGS="$cf_trim_CFLAGS"
1852         CPPFLAGS="$cf_trim_CPPFLAGS"
1853         if test "$cf_cv_cc_u_d_options" = yes ; then
1854                 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1855                                 sed -e 's/-D/-U/g' -e 's/=[[^   ]]*//g'`
1856                 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1857         fi
1858         CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1859 fi
1860
1861 ])dnl
1862 dnl ---------------------------------------------------------------------------
1863 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
1864 dnl ------------
1865 dnl Append definitions and rules for the given programs to the subdirectory
1866 dnl Makefiles, and the recursion rule for the top-level Makefile.
1867 dnl
1868 dnl parameters
1869 dnl     $1 = script to run
1870 dnl     $2 = list of subdirectories
1871 dnl
1872 dnl variables
1873 dnl     $AWK
1874 AC_DEFUN([CF_PRG_RULES],
1875 [
1876 for cf_dir in $2
1877 do
1878         if test ! -d $srcdir/$cf_dir; then
1879                 continue
1880         elif test -f $srcdir/$cf_dir/programs; then
1881                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
1882         fi
1883 done
1884
1885 ])dnl
1886 dnl ---------------------------------------------------------------------------
1887 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1888 dnl --------------
1889 dnl Check if C (preprocessor) -U and -D options are processed in the order
1890 dnl given rather than by type of option.  Some compilers insist on apply all
1891 dnl of the -U options after all of the -D options.  Others allow mixing them,
1892 dnl and may predefine symbols that conflict with those we define.
1893 AC_DEFUN([CF_PROG_CC_U_D],
1894 [
1895 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1896         cf_save_CPPFLAGS="$CPPFLAGS"
1897         CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1898         AC_TRY_COMPILE([],[
1899 #ifndef U_D_OPTIONS
1900 make an undefined-error
1901 #endif
1902 #ifdef  D_U_OPTIONS
1903 make a defined-error
1904 #endif
1905         ],[
1906         cf_cv_cc_u_d_options=yes],[
1907         cf_cv_cc_u_d_options=no])
1908         CPPFLAGS="$cf_save_CPPFLAGS"
1909 ])
1910 ])dnl
1911 dnl ---------------------------------------------------------------------------
1912 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1913 dnl ----------------
1914 dnl Remove all -U and -D options that refer to the given symbol from a list
1915 dnl of C compiler options.  This works around the problem that not all
1916 dnl compilers process -U and -D options from left-to-right, so a -U option
1917 dnl cannot be used to cancel the effect of a preceding -D option.
1918 dnl
1919 dnl $1 = target (which could be the same as the source variable)
1920 dnl $2 = source (including '$')
1921 dnl $3 = symbol to remove
1922 define([CF_REMOVE_DEFINE],
1923 [
1924 # remove $3 symbol from $2
1925 $1=`echo "$2" | \
1926         sed     -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[[       ]]/ /g' \
1927                 -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[$]//g'`
1928 ])dnl
1929 dnl ---------------------------------------------------------------------------
1930 dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
1931 dnl ---------------
1932 dnl signal handler, but there are some gcc depedencies in that recommendation.
1933 dnl Try anyway.
1934 AC_DEFUN([CF_SIG_ATOMIC_T],
1935 [
1936 AC_MSG_CHECKING(for signal global datatype)
1937 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
1938         for cf_type in \
1939                 "volatile sig_atomic_t" \
1940                 "sig_atomic_t" \
1941                 "int"
1942         do
1943         AC_TRY_COMPILE([
1944 #include <sys/types.h>
1945 #include <signal.h>
1946 #include <stdio.h>
1947
1948 extern $cf_type x;
1949 $cf_type x;
1950 static void handler(int sig)
1951 {
1952         x = 5;
1953 }],
1954                 [signal(SIGINT, handler);
1955                  x = 1],
1956                 [cf_cv_sig_atomic_t=$cf_type],
1957                 [cf_cv_sig_atomic_t=no])
1958                 test "$cf_cv_sig_atomic_t" != no && break
1959         done
1960         ])
1961 AC_MSG_RESULT($cf_cv_sig_atomic_t)
1962 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
1963 ])dnl
1964 dnl ---------------------------------------------------------------------------
1965 dnl CF_SUBDIR_PATH version: 5 updated: 2007/07/29 09:55:12
1966 dnl --------------
1967 dnl Construct a search-list for a nonstandard header/lib-file
1968 dnl     $1 = the variable to return as result
1969 dnl     $2 = the package name
1970 dnl     $3 = the subdirectory, e.g., bin, include or lib
1971 AC_DEFUN([CF_SUBDIR_PATH],
1972 [$1=""
1973
1974 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
1975 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
1976 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
1977 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
1978 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
1979 ])dnl
1980 dnl ---------------------------------------------------------------------------
1981 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1982 dnl ------------------
1983 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1984 dnl older SCO configurations.
1985 AC_DEFUN([CF_SYS_TIME_SELECT],
1986 [
1987 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1988 AC_CACHE_VAL(cf_cv_sys_time_select,[
1989 AC_TRY_COMPILE([
1990 #include <sys/types.h>
1991 #ifdef HAVE_SYS_TIME_H
1992 #include <sys/time.h>
1993 #endif
1994 #ifdef HAVE_SYS_SELECT_H
1995 #include <sys/select.h>
1996 #endif
1997 ],[],[cf_cv_sys_time_select=yes],
1998      [cf_cv_sys_time_select=no])
1999      ])
2000 AC_MSG_RESULT($cf_cv_sys_time_select)
2001 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2002 ])dnl
2003 dnl ---------------------------------------------------------------------------
2004 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
2005 dnl --------------
2006 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
2007 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
2008 dnl but some packagers change this, breaking various applications.
2009 AC_DEFUN([CF_TERM_HEADER],[
2010 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2011 case ${cf_cv_ncurses_header} in #(vi
2012 */ncurses.h|*/ncursesw.h) #(vi
2013         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2014         ;;
2015 *)
2016         cf_term_header=term.h
2017         ;;
2018 esac
2019
2020 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2021 do
2022 AC_TRY_COMPILE([#include <stdio.h>
2023 #include <${cf_cv_ncurses_header-curses.h}>
2024 #include <$cf_test>
2025 ],[int x = auto_left_margin],[
2026         cf_cv_term_header="$cf_test"],[
2027         cf_cv_term_header=unknown
2028         ])
2029         test "$cf_cv_term_header" != unknown && break
2030 done
2031 ])
2032
2033 # Set definitions to allow ifdef'ing to accommodate subdirectories
2034
2035 case $cf_cv_term_header in # (vi
2036 *term.h)
2037         AC_DEFINE(HAVE_TERM_H)
2038         ;;
2039 esac
2040
2041 case $cf_cv_term_header in # (vi
2042 ncurses/term.h) #(vi
2043         AC_DEFINE(HAVE_NCURSES_TERM_H)
2044         ;;
2045 ncursesw/term.h)
2046         AC_DEFINE(HAVE_NCURSESW_TERM_H)
2047         ;;
2048 esac
2049 ])dnl
2050 dnl ---------------------------------------------------------------------------
2051 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2052 dnl --------
2053 dnl Make an uppercase version of a variable
2054 dnl $1=uppercase($2)
2055 AC_DEFUN([CF_UPPER],
2056 [
2057 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2058 ])dnl
2059 dnl ---------------------------------------------------------------------------
2060 dnl CF_UTF8_LIB version: 5 updated: 2008/10/17 19:37:52
2061 dnl -----------
2062 dnl Check for multibyte support, and if not found, utf8 compatibility library
2063 AC_DEFUN([CF_UTF8_LIB],
2064 [
2065 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
2066         cf_save_LIBS="$LIBS"
2067         AC_TRY_LINK([
2068 #include <stdlib.h>],[putwc(0,0);],
2069         [cf_cv_utf8_lib=yes],
2070         [CF_FIND_LINKAGE([
2071 #include <libutf8.h>],[putwc(0,0);],utf8,
2072                 [cf_cv_utf8_lib=add-on],
2073                 [cf_cv_utf8_lib=no])
2074 ])])
2075
2076 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
2077 # ncurses/ncursesw:
2078 if test "$cf_cv_utf8_lib" = "add-on" ; then
2079         AC_DEFINE(HAVE_LIBUTF8_H)
2080         CF_ADD_INCDIR($cf_cv_header_path_utf8)
2081         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
2082         LIBS="-lutf8 $LIBS"
2083 fi
2084 ])dnl
2085 dnl ---------------------------------------------------------------------------
2086 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2087 dnl ----------
2088 dnl Use AC_VERBOSE w/o the warnings
2089 AC_DEFUN([CF_VERBOSE],
2090 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
2091 CF_MSG_LOG([$1])
2092 ])dnl
2093 dnl ---------------------------------------------------------------------------
2094 dnl CF_WCHAR_TYPE version: 2 updated: 2004/01/17 19:18:20
2095 dnl -------------
2096 dnl Check if type wide-character type $1 is declared, and if so, which header
2097 dnl file is needed.  The second parameter is used to set a shell variable when
2098 dnl the type is not found.  The first parameter sets a shell variable for the
2099 dnl opposite sense.
2100 AC_DEFUN([CF_WCHAR_TYPE],
2101 [
2102 # This is needed on Tru64 5.0 to declare $1
2103 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
2104 AC_TRY_COMPILE([
2105 #include <stdlib.h>
2106 #include <stdarg.h>
2107 #include <stdio.h>
2108 #ifdef HAVE_LIBUTF8_H
2109 #include <libutf8.h>
2110 #endif],
2111         [$1 state],
2112         [cf_cv_$1=no],
2113         [AC_TRY_COMPILE([
2114 #include <stdlib.h>
2115 #include <stdarg.h>
2116 #include <stdio.h>
2117 #include <wchar.h>
2118 #ifdef HAVE_LIBUTF8_H
2119 #include <libutf8.h>
2120 #endif],
2121         [$1 value],
2122         [cf_cv_$1=yes],
2123         [cf_cv_$1=unknown])])])
2124
2125 if test "$cf_cv_$1" = yes ; then
2126         AC_DEFINE(NEED_WCHAR_H)
2127         NEED_WCHAR_H=1
2128 fi
2129
2130 ifelse($2,,,[
2131 # if we do not find $1 in either place, use substitution to provide a fallback.
2132 if test "$cf_cv_$1" = unknown ; then
2133         $2=1
2134 fi
2135 ])
2136 ifelse($3,,,[
2137 # if we find $1 in either place, use substitution to provide a fallback.
2138 if test "$cf_cv_$1" != unknown ; then
2139         $3=1
2140 fi
2141 ])
2142 ])dnl
2143 dnl ---------------------------------------------------------------------------
2144 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
2145 dnl ------------------
2146 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
2147 dnl libraries.
2148 AC_DEFUN([CF_WITH_CURSES_DIR],[
2149 AC_ARG_WITH(curses-dir,
2150         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
2151         [CF_PATH_SYNTAX(withval)
2152          cf_cv_curses_dir=$withval],
2153         [cf_cv_curses_dir=no])
2154 ])dnl
2155 dnl ---------------------------------------------------------------------------
2156 dnl CF_XOPEN_CURSES version: 8 updated: 2003/11/07 19:47:46
2157 dnl ---------------
2158 dnl Test if we should define X/Open source for curses, needed on Digital Unix
2159 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
2160 dnl
2161 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
2162 dnl as getbegy().  The latter is better design, but the former is standard.
2163 AC_DEFUN([CF_XOPEN_CURSES],
2164 [
2165 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2166 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
2167 AC_TRY_LINK([
2168 #include <stdlib.h>
2169 #include <${cf_cv_ncurses_header-curses.h}>],[
2170         long x = winnstr(stdscr, "", 0);
2171         int x1, y1;
2172         getbegyx(stdscr, y1, x1)],
2173         [cf_cv_need_xopen_extension=no],
2174         [AC_TRY_LINK([
2175 #define _XOPEN_SOURCE_EXTENDED
2176 #include <stdlib.h>
2177 #include <${cf_cv_ncurses_header-curses.h}>],[
2178         long x = winnstr(stdscr, "", 0);
2179         int x1, y1;
2180         getbegyx(stdscr, y1, x1)],
2181         [cf_cv_need_xopen_extension=yes],
2182         [cf_cv_need_xopen_extension=unknown])])])
2183 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
2184 ])dnl
2185 dnl ---------------------------------------------------------------------------
2186 dnl CF_XOPEN_SOURCE version: 29 updated: 2009/07/16 21:07:04
2187 dnl ---------------
2188 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2189 dnl or adapt to the vendor's definitions to get equivalent functionality,
2190 dnl without losing the common non-POSIX features.
2191 dnl
2192 dnl Parameters:
2193 dnl     $1 is the nominal value for _XOPEN_SOURCE
2194 dnl     $2 is the nominal value for _POSIX_C_SOURCE
2195 AC_DEFUN([CF_XOPEN_SOURCE],[
2196
2197 AC_REQUIRE([CF_PROG_CC_U_D])
2198
2199 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
2200 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
2201
2202 case $host_os in #(vi
2203 aix[[456]]*) #(vi
2204         CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
2205         ;;
2206 freebsd*|dragonfly*) #(vi
2207         # 5.x headers associate
2208         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2209         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2210         cf_POSIX_C_SOURCE=200112L
2211         cf_XOPEN_SOURCE=600
2212         CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2213         ;;
2214 hpux11*) #(vi
2215         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
2216         ;;
2217 hpux*) #(vi
2218         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
2219         ;;
2220 irix[[56]].*) #(vi
2221         CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
2222         ;;
2223 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
2224         CF_GNU_SOURCE
2225         ;;
2226 mirbsd*) #(vi
2227         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
2228         ;;
2229 netbsd*) #(vi
2230         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2231         ;;
2232 openbsd*) #(vi
2233         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2234         ;;
2235 osf[[45]]*) #(vi
2236         CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
2237         ;;
2238 nto-qnx*) #(vi
2239         CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
2240         ;;
2241 sco*) #(vi
2242         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2243         ;;
2244 solaris*) #(vi
2245         CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
2246         ;;
2247 *)
2248         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2249         AC_TRY_COMPILE([#include <sys/types.h>],[
2250 #ifndef _XOPEN_SOURCE
2251 make an error
2252 #endif],
2253         [cf_cv_xopen_source=no],
2254         [cf_save="$CPPFLAGS"
2255          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2256          AC_TRY_COMPILE([#include <sys/types.h>],[
2257 #ifdef _XOPEN_SOURCE
2258 make an error
2259 #endif],
2260         [cf_cv_xopen_source=no],
2261         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2262         CPPFLAGS="$cf_save"
2263         ])
2264 ])
2265         if test "$cf_cv_xopen_source" != no ; then
2266                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2267                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2268                 test "$cf_cv_cc_u_d_options" = yes && \
2269                         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
2270                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
2271         fi
2272         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2273         ;;
2274 esac
2275 ])
2276 dnl ---------------------------------------------------------------------------
2277 dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41
2278 dnl -----------
2279 dnl Check for Xaw (Athena) libraries
2280 dnl
2281 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
2282 AC_DEFUN([CF_X_ATHENA],
2283 [AC_REQUIRE([CF_X_TOOLKIT])
2284 cf_x_athena=${cf_x_athena-Xaw}
2285
2286 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
2287 withval=
2288 AC_ARG_WITH(Xaw3d,
2289         [  --with-Xaw3d            link with Xaw 3d library])
2290 if test "$withval" = yes ; then
2291         cf_x_athena=Xaw3d
2292         AC_MSG_RESULT(yes)
2293 else
2294         AC_MSG_RESULT(no)
2295 fi
2296
2297 AC_MSG_CHECKING(if you want to link with neXT Athena library)
2298 withval=
2299 AC_ARG_WITH(neXtaw,
2300         [  --with-neXtaw           link with neXT Athena library])
2301 if test "$withval" = yes ; then
2302         cf_x_athena=neXtaw
2303         AC_MSG_RESULT(yes)
2304 else
2305         AC_MSG_RESULT(no)
2306 fi
2307
2308 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
2309 withval=
2310 AC_ARG_WITH(XawPlus,
2311         [  --with-XawPlus          link with Athena-Plus library])
2312 if test "$withval" = yes ; then
2313         cf_x_athena=XawPlus
2314         AC_MSG_RESULT(yes)
2315 else
2316         AC_MSG_RESULT(no)
2317 fi
2318
2319 AC_CHECK_LIB(Xext,XextCreateExtension,
2320         [LIBS="-lXext $LIBS"])
2321
2322 cf_x_athena_lib=""
2323
2324 CF_X_ATHENA_CPPFLAGS($cf_x_athena)
2325 CF_X_ATHENA_LIBS($cf_x_athena)
2326 ])dnl
2327 dnl ---------------------------------------------------------------------------
2328 dnl CF_X_ATHENA_CPPFLAGS version: 3 updated: 2009/01/11 15:33:39
2329 dnl --------------------
2330 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2331 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2332 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
2333 [
2334 cf_x_athena_root=ifelse($1,,Xaw,$1)
2335 cf_x_athena_include=""
2336
2337 for cf_path in default \
2338         /usr/contrib/X11R6 \
2339         /usr/contrib/X11R5 \
2340         /usr/lib/X11R5 \
2341         /usr/local
2342 do
2343         if test -z "$cf_x_athena_include" ; then
2344                 cf_save="$CPPFLAGS"
2345                 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
2346                 if test $cf_path != default ; then
2347                         CPPFLAGS="$cf_save -I$cf_path/include"
2348                         AC_MSG_CHECKING(for $cf_test in $cf_path)
2349                 else
2350                         AC_MSG_CHECKING(for $cf_test)
2351                 fi
2352                 AC_TRY_COMPILE([
2353 #include <X11/Intrinsic.h>
2354 #include <$cf_test>],[],
2355                         [cf_result=yes],
2356                         [cf_result=no])
2357                 AC_MSG_RESULT($cf_result)
2358                 if test "$cf_result" = yes ; then
2359                         cf_x_athena_include=$cf_path
2360                         break
2361                 else
2362                         CPPFLAGS="$cf_save"
2363                 fi
2364         fi
2365 done
2366
2367 if test -z "$cf_x_athena_include" ; then
2368         AC_MSG_WARN(
2369 [Unable to successfully find Athena header files with test program])
2370 elif test "$cf_x_athena_include" != default ; then
2371         CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include"
2372 fi
2373 ])
2374 dnl ---------------------------------------------------------------------------
2375 dnl CF_X_ATHENA_LIBS version: 7 updated: 2008/03/23 14:46:03
2376 dnl ----------------
2377 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2378 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2379 AC_DEFUN([CF_X_ATHENA_LIBS],
2380 [AC_REQUIRE([CF_X_TOOLKIT])
2381 cf_x_athena_root=ifelse($1,,Xaw,$1)
2382 cf_x_athena_lib=""
2383
2384 for cf_path in default \
2385         /usr/contrib/X11R6 \
2386         /usr/contrib/X11R5 \
2387         /usr/lib/X11R5 \
2388         /usr/local
2389 do
2390         for cf_lib in \
2391                 "-l$cf_x_athena_root -lXmu" \
2392                 "-l$cf_x_athena_root -lXpm -lXmu" \
2393                 "-l${cf_x_athena_root}_s -lXmu_s"
2394         do
2395                 if test -z "$cf_x_athena_lib" ; then
2396                         cf_save="$LIBS"
2397                         cf_test=XawSimpleMenuAddGlobalActions
2398                         if test $cf_path != default ; then
2399                                 LIBS="-L$cf_path/lib $cf_lib $LIBS"
2400                                 AC_MSG_CHECKING(for $cf_lib in $cf_path)
2401                         else
2402                                 LIBS="$cf_lib $LIBS"
2403                                 AC_MSG_CHECKING(for $cf_test in $cf_lib)
2404                         fi
2405                         AC_TRY_LINK([],[$cf_test()],
2406                                 [cf_result=yes],
2407                                 [cf_result=no])
2408                         AC_MSG_RESULT($cf_result)
2409                         if test "$cf_result" = yes ; then
2410                                 cf_x_athena_lib="$cf_lib"
2411                                 break
2412                         fi
2413                         LIBS="$cf_save"
2414                 fi
2415         done
2416 done
2417
2418 if test -z "$cf_x_athena_lib" ; then
2419         AC_MSG_ERROR(
2420 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
2421 fi
2422
2423 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2424 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2425 ])
2426 dnl ---------------------------------------------------------------------------
2427 dnl CF_X_TOOLKIT version: 12 updated: 2008/03/23 15:04:54
2428 dnl ------------
2429 dnl Check for X Toolkit libraries
2430 dnl
2431 AC_DEFUN([CF_X_TOOLKIT],
2432 [
2433 AC_REQUIRE([AC_PATH_XTRA])
2434 AC_REQUIRE([CF_CHECK_CACHE])
2435
2436 # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
2437
2438 cf_have_X_LIBS=no
2439
2440 LDFLAGS="$X_LIBS $LDFLAGS"
2441 CF_CHECK_CFLAGS($X_CFLAGS)
2442
2443 AC_CHECK_FUNC(XOpenDisplay,,[
2444 AC_CHECK_LIB(X11,XOpenDisplay,
2445         [LIBS="-lX11 $LIBS"],,
2446         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2447
2448 AC_CHECK_FUNC(XtAppInitialize,,[
2449 AC_CHECK_LIB(Xt, XtAppInitialize,
2450         [AC_DEFINE(HAVE_LIBXT)
2451          cf_have_X_LIBS=Xt
2452          LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
2453         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2454
2455 if test $cf_have_X_LIBS = no ; then
2456         AC_MSG_WARN(
2457 [Unable to successfully link X Toolkit library (-lXt) with
2458 test program.  You will have to check and add the proper libraries by hand
2459 to makefile.])
2460 fi
2461 ])dnl
2462 dnl ---------------------------------------------------------------------------
2463 dnl CF__CURSES_HEAD version: 1 updated: 2009/07/16 19:32:31
2464 dnl ---------------
2465 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
2466 dnl are both available.
2467 define([CF__CURSES_HEAD],[
2468 #ifdef HAVE_XCURSES
2469 #include <xcurses.h>
2470 char * XCursesProgramName = "test";
2471 #else
2472 #include <${cf_cv_ncurses_header-curses.h}>
2473 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
2474 #include <ncursesw/term.h>
2475 #elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
2476 #include <ncurses/term.h>
2477 #elif defined(HAVE_TERM_H)
2478 #include <term.h>
2479 #endif
2480 #endif
2481 ])