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