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