]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/aclocal.m4
ncurses 5.6
[ncurses.git] / test / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2003-2005,2006 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.17 2006/12/03 00:10:15 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: 7 updated: 2004/04/25 17:48:30
44 dnl -------------
45 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
46 dnl The second parameter if given makes this macro verbose.
47 dnl
48 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
49 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
50 dnl confused by the quotes (which require backslashes to keep them usable).
51 AC_DEFUN([CF_ADD_CFLAGS],
52 [
53 cf_fix_cppflags=no
54 cf_new_cflags=
55 cf_new_cppflags=
56 cf_new_extra_cppflags=
57
58 for cf_add_cflags in $1
59 do
60 case $cf_fix_cppflags in
61 no)
62         case $cf_add_cflags in #(vi
63         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
64                 case $cf_add_cflags in
65                 -D*)
66                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
67
68                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
69                         && test -z "${cf_tst_cflags}" \
70                         && cf_fix_cppflags=yes
71
72                         if test $cf_fix_cppflags = yes ; then
73                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
74                                 continue
75                         elif test "${cf_tst_cflags}" = "\"'" ; then
76                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
77                                 continue
78                         fi
79                         ;;
80                 esac
81                 case "$CPPFLAGS" in
82                 *$cf_add_cflags) #(vi
83                         ;;
84                 *) #(vi
85                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
86                         ;;
87                 esac
88                 ;;
89         *)
90                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
91                 ;;
92         esac
93         ;;
94 yes)
95         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
96
97         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
98
99         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
100         && test -z "${cf_tst_cflags}" \
101         && cf_fix_cppflags=no
102         ;;
103 esac
104 done
105
106 if test -n "$cf_new_cflags" ; then
107         ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
108         CFLAGS="$CFLAGS $cf_new_cflags"
109 fi
110
111 if test -n "$cf_new_cppflags" ; then
112         ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
113         CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
114 fi
115
116 if test -n "$cf_new_extra_cppflags" ; then
117         ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
118         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
119 fi
120
121 AC_SUBST(EXTRA_CPPFLAGS)
122
123 ])dnl
124 dnl ---------------------------------------------------------------------------
125 dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52
126 dnl -------------
127 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
128 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
129 dnl but old versions (and some misinstalled ones) need that.  To make things
130 dnl worse, gcc 3.x gives error messages if -I/usr/local/include is added to
131 dnl the include-path).
132 AC_DEFUN([CF_ADD_INCDIR],
133 [
134 for cf_add_incdir in $1
135 do
136         while true
137         do
138                 case $cf_add_incdir in
139                 /usr/include) # (vi
140                         ;;
141                 /usr/local/include) # (vi
142                         if test "$GCC" = yes
143                         then
144                                 cf_save_CPPFLAGS="$CPPFLAGS"
145                                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
146                                 AC_TRY_COMPILE([#include <stdio.h>],
147                                                 [printf("Hello")],
148                                                 [],
149                                                 [CPPFLAGS="$cf_save_CPPFLAGS"])
150                         fi
151                         ;;
152                 *) # (vi
153                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
154                         ;;
155                 esac
156                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
157                 test "$cf_top_incdir" = "$cf_add_incdir" && break
158                 cf_add_incdir="$cf_top_incdir"
159         done
160 done
161 ])dnl
162 dnl ---------------------------------------------------------------------------
163 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
164 dnl ----------------
165 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
166 dnl in the sharutils 4.2 distribution.
167 AC_DEFUN([CF_ANSI_CC_CHECK],
168 [
169 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
170 cf_cv_ansi_cc=no
171 cf_save_CFLAGS="$CFLAGS"
172 cf_save_CPPFLAGS="$CPPFLAGS"
173 # Don't try gcc -ansi; that turns off useful extensions and
174 # breaks some systems' header files.
175 # AIX                   -qlanglvl=ansi
176 # Ultrix and OSF/1      -std1
177 # HP-UX                 -Aa -D_HPUX_SOURCE
178 # SVR4                  -Xc
179 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
180 for cf_arg in "-DCC_HAS_PROTOS" \
181         "" \
182         -qlanglvl=ansi \
183         -std1 \
184         -Ae \
185         "-Aa -D_HPUX_SOURCE" \
186         -Xc
187 do
188         CF_ADD_CFLAGS($cf_arg)
189         AC_TRY_COMPILE(
190 [
191 #ifndef CC_HAS_PROTOS
192 #if !defined(__STDC__) || (__STDC__ != 1)
193 choke me
194 #endif
195 #endif
196 ],[
197         int test (int i, double x);
198         struct s1 {int (*f) (int a);};
199         struct s2 {int (*f) (double a);};],
200         [cf_cv_ansi_cc="$cf_arg"; break])
201 done
202 CFLAGS="$cf_save_CFLAGS"
203 CPPFLAGS="$cf_save_CPPFLAGS"
204 ])
205
206 if test "$cf_cv_ansi_cc" != "no"; then
207 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
208         CF_ADD_CFLAGS($cf_cv_ansi_cc)
209 else
210         AC_DEFINE(CC_HAS_PROTOS)
211 fi
212 fi
213 ])dnl
214 dnl ---------------------------------------------------------------------------
215 dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
216 dnl ---------------
217 dnl For programs that must use an ANSI compiler, obtain compiler options that
218 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
219 dnl macros, since tools such as unproto can fake prototypes, but only part of
220 dnl the preprocessor.
221 AC_DEFUN([CF_ANSI_CC_REQD],
222 [AC_REQUIRE([CF_ANSI_CC_CHECK])
223 if test "$cf_cv_ansi_cc" = "no"; then
224         AC_ERROR(
225 [Your compiler does not appear to recognize prototypes.
226 You have the following choices:
227         a. adjust your compiler options
228         b. get an up-to-date compiler
229         c. use a wrapper such as unproto])
230 fi
231 ])dnl
232 dnl ---------------------------------------------------------------------------
233 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
234 dnl -------------
235 dnl Allow user to enable a normally-off option.
236 AC_DEFUN([CF_ARG_ENABLE],
237 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
238 dnl ---------------------------------------------------------------------------
239 dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
240 dnl -------------
241 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
242 dnl values.
243 dnl
244 dnl Parameters:
245 dnl $1 = option name
246 dnl $2 = help-string
247 dnl $3 = action to perform if option is not default
248 dnl $4 = action if perform if option is default
249 dnl $5 = default option value (either 'yes' or 'no')
250 AC_DEFUN([CF_ARG_OPTION],
251 [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
252   if test "$enableval" != "$5" ; then
253 ifelse($3,,[    :]dnl
254 ,[    $3]) ifelse($4,,,[
255   else
256     $4])
257   fi],[enableval=$5 ifelse($4,,,[
258   $4
259 ])dnl
260   ])])dnl
261 dnl ---------------------------------------------------------------------------
262 dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
263 dnl --------------
264 dnl Check if we're accidentally using a cache from a different machine.
265 dnl Derive the system name, as a check for reusing the autoconf cache.
266 dnl
267 dnl If we've packaged config.guess and config.sub, run that (since it does a
268 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
269 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
270 dnl which is useful in cross-compiles.
271 dnl
272 dnl Note: we would use $ac_config_sub, but that is one of the places where
273 dnl autoconf 2.5x broke compatibility with autoconf 2.13
274 AC_DEFUN([CF_CHECK_CACHE],
275 [
276 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
277         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
278         system_name="$host_os"
279 else
280         system_name="`(uname -s -r) 2>/dev/null`"
281         if test -z "$system_name" ; then
282                 system_name="`(hostname) 2>/dev/null`"
283         fi
284 fi
285 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
286 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
287
288 test -z "$system_name" && system_name="$cf_cv_system_name"
289 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
290
291 if test ".$system_name" != ".$cf_cv_system_name" ; then
292         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
293         AC_ERROR("Please remove config.cache and try again.")
294 fi
295 ])dnl
296 dnl ---------------------------------------------------------------------------
297 dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
298 dnl ---------------
299 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
300 dnl a build-configuration such as imake.  These have the pitfall that they
301 dnl often contain compiler-specific options which we cannot use, mixed with
302 dnl preprocessor options that we usually can.
303 AC_DEFUN([CF_CHECK_CFLAGS],
304 [
305 CF_VERBOSE(checking additions to CFLAGS)
306 cf_check_cflags="$CFLAGS"
307 cf_check_cppflags="$CPPFLAGS"
308 CF_ADD_CFLAGS($1,yes)
309 if test "$cf_check_cflags" != "$CFLAGS" ; then
310 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
311         [CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
312          if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
313                  CF_VERBOSE(but keeping change to \$CPPFLAGS)
314          fi
315          CFLAGS="$cf_check_flags"])
316 fi
317 ])dnl
318 dnl ---------------------------------------------------------------------------
319 dnl CF_CURSES_ACS_MAP version: 3 updated: 2003/05/17 22:19:02
320 dnl -----------------
321 dnl Check for likely values of acs_map[]:
322 AC_DEFUN([CF_CURSES_ACS_MAP],
323 [
324 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
325 cf_cv_curses_acs_map=unknown
326 for name in acs_map _acs_map __acs_map _nc_acs_map
327 do
328 AC_TRY_LINK([
329 #include <${cf_cv_ncurses_header-curses.h}>
330 ],[
331 $name['k'] = ACS_PLUS
332 ],[cf_cv_curses_acs_map=$name; break])
333 done
334 ])
335
336 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
337 ])
338 dnl ---------------------------------------------------------------------------
339 dnl CF_CURSES_CHECK_TYPE version: 2 updated: 2003/03/01 23:40:33
340 dnl --------------------
341 dnl Check if curses.h defines the given type
342 AC_DEFUN([CF_CURSES_CHECK_TYPE],
343 [
344 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header-curses.h})
345 AC_TRY_COMPILE([
346 #ifndef _XOPEN_SOURCE_EXTENDED
347 #define _XOPEN_SOURCE_EXTENDED
348 #endif
349 #include <${cf_cv_ncurses_header-curses.h}>],[
350 $1 foo
351 ],cf_result=yes,cf_result=no)
352 AC_MSG_RESULT($cf_result)
353 if test $cf_result = yes ; then
354         CF_UPPER(cf_result,have_type_$1)
355         AC_DEFINE_UNQUOTED($cf_result)
356 else
357         AC_DEFINE_UNQUOTED($1,$2)
358 fi
359 ])dnl
360 dnl ---------------------------------------------------------------------------
361 dnl CF_CURSES_CPPFLAGS version: 9 updated: 2006/02/04 19:44:43
362 dnl ------------------
363 dnl Look for the curses headers.
364 AC_DEFUN([CF_CURSES_CPPFLAGS],[
365
366 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
367 cf_cv_curses_incdir=no
368 case $host_os in #(vi
369 hpux10.*) #(vi
370         test -d /usr/include/curses_colr && \
371         cf_cv_curses_incdir="-I/usr/include/curses_colr"
372         ;;
373 sunos3*|sunos4*)
374         test -d /usr/5lib && \
375         test -d /usr/5include && \
376         cf_cv_curses_incdir="-I/usr/5include"
377         ;;
378 esac
379 ])
380 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
381
382 CF_CURSES_HEADER
383 CF_TERM_HEADER
384 ])dnl
385 dnl ---------------------------------------------------------------------------
386 dnl CF_CURSES_HEADER version: 1 updated: 2005/12/31 13:28:25
387 dnl ----------------
388 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
389 dnl variations of ncurses' installs.
390 dnl
391 dnl See also CF_NCURSES_HEADER, which sets the same cache variable.
392 AC_DEFUN([CF_CURSES_HEADER],[
393 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
394 cf_cv_ncurses_header=none
395 for cf_header in \
396         curses.h \
397         ncurses.h \
398         ncurses/curses.h \
399         ncurses/ncurses.h
400 do
401 AC_TRY_COMPILE([#include <${cf_header}>],
402         [initscr(); tgoto("?", 0,0)],
403         [cf_cv_ncurses_header=$cf_header; break],[])
404 done
405 ])
406
407 if test "$cf_cv_ncurses_header" = none ; then
408         AC_MSG_ERROR(No curses header-files found)
409 fi
410
411 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
412 AC_CHECK_HEADERS($cf_cv_ncurses_header)
413 ])dnl
414 dnl ---------------------------------------------------------------------------
415 dnl CF_CURSES_LIBS version: 24 updated: 2006/02/04 19:44:43
416 dnl --------------
417 dnl Look for the curses libraries.  Older curses implementations may require
418 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
419 AC_DEFUN([CF_CURSES_LIBS],[
420
421 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
422 AC_MSG_CHECKING(if we have identified curses libraries)
423 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
424         [initscr(); tgoto("?", 0,0)],
425         cf_result=yes,
426         cf_result=no)
427 AC_MSG_RESULT($cf_result)
428
429 if test "$cf_result" = no ; then
430 case $host_os in #(vi
431 freebsd*) #(vi
432         AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
433         ;;
434 hpux10.*) #(vi
435         AC_CHECK_LIB(cur_colr,initscr,[
436                 LIBS="-lcur_colr $LIBS"
437                 ac_cv_func_initscr=yes
438                 ],[
439         AC_CHECK_LIB(Hcurses,initscr,[
440                 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
441                 LIBS="-lHcurses $LIBS"
442                 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
443                 ac_cv_func_initscr=yes
444                 ])])
445         ;;
446 linux*) # Suse Linux does not follow /usr/lib convention
447         LIBS="$LIBS -L/lib"
448         ;;
449 sunos3*|sunos4*)
450         test -d /usr/5lib && \
451         LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap"
452         ac_cv_func_initscr=yes
453         ;;
454 esac
455
456 if test ".$ac_cv_func_initscr" != .yes ; then
457         cf_save_LIBS="$LIBS"
458         cf_term_lib=""
459         cf_curs_lib=""
460
461         if test ".${cf_cv_ncurses_version-no}" != .no
462         then
463                 cf_check_list="ncurses curses cursesX"
464         else
465                 cf_check_list="cursesX curses ncurses"
466         fi
467
468         # Check for library containing tgoto.  Do this before curses library
469         # because it may be needed to link the test-case for initscr.
470         AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
471                 for cf_term_lib in $cf_check_list termcap termlib unknown
472                 do
473                         AC_CHECK_LIB($cf_term_lib,tgoto,[break])
474                 done
475         ])
476
477         # Check for library containing initscr
478         test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
479         for cf_curs_lib in $cf_check_list xcurses jcurses unknown
480         do
481                 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
482         done
483         test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
484
485         LIBS="-l$cf_curs_lib $cf_save_LIBS"
486         if test "$cf_term_lib" = unknown ; then
487                 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
488                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
489                         [initscr()],
490                         [cf_result=yes],
491                         [cf_result=no])
492                 AC_MSG_RESULT($cf_result)
493                 test $cf_result = no && AC_ERROR(Cannot link curses library)
494         elif test "$cf_curs_lib" = "$cf_term_lib" ; then
495                 :
496         elif test "$cf_term_lib" != predefined ; then
497                 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
498                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
499                         [initscr(); tgoto((char *)0, 0, 0);],
500                         [cf_result=no],
501                         [
502                         LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
503                         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
504                                 [initscr()],
505                                 [cf_result=yes],
506                                 [cf_result=error])
507                         ])
508                 AC_MSG_RESULT($cf_result)
509         fi
510 fi
511 fi
512
513 ])dnl
514 dnl ---------------------------------------------------------------------------
515 dnl CF_CURSES_WACS_MAP version: 3 updated: 2003/05/17 22:19:02
516 dnl ------------------
517 dnl Check for likely values of wacs_map[]:
518 AC_DEFUN([CF_CURSES_WACS_MAP],
519 [
520 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
521         cf_cv_curses_wacs_map=unknown
522         for name in wacs_map _wacs_map __wacs_map _nc_wacs
523         do
524         AC_TRY_LINK([
525 #ifndef _XOPEN_SOURCE_EXTENDED
526 #define _XOPEN_SOURCE_EXTENDED
527 #endif
528 #include <${cf_cv_ncurses_header-curses.h}>],
529         [$name['k'] = *WACS_PLUS],
530         [cf_cv_curses_wacs_map=$name
531          break])
532         done])
533 ])
534 dnl ---------------------------------------------------------------------------
535 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
536 dnl ----------
537 dnl "dirname" is not portable, so we fake it with a shell script.
538 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
539 dnl ---------------------------------------------------------------------------
540 dnl CF_ENABLE_WARNINGS version: 3 updated: 2003/05/24 14:24:29
541 dnl ------------------
542 dnl Configure-option to enable gcc warnings
543 AC_DEFUN([CF_ENABLE_WARNINGS],[
544 if ( test "$GCC" = yes || test "$GXX" = yes )
545 then
546 AC_MSG_CHECKING(if you want to turn on gcc warnings)
547 CF_ARG_ENABLE(warnings,
548         [  --enable-warnings       test: turn on gcc compiler warnings],
549         [with_warnings=yes],
550         [with_warnings=no])
551 AC_MSG_RESULT($with_warnings)
552 if test "$with_warnings" = "yes"
553 then
554         CF_GCC_WARNINGS
555 fi
556 fi
557 ])dnl
558 dnl ---------------------------------------------------------------------------
559 dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
560 dnl ---------------
561 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
562 dnl prefer a standard location, and use -L options only if we do not find the
563 dnl library in the standard library location(s).
564 dnl     $1 = library name
565 dnl     $2 = library class, usually the same as library name
566 dnl     $3 = includes
567 dnl     $4 = code fragment to compile/link
568 dnl     $5 = corresponding function-name
569 dnl     $6 = flag, nonnull if failure should not cause an error-exit
570 dnl
571 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
572 dnl to use a -L option.
573 AC_DEFUN([CF_FIND_LIBRARY],
574 [
575         eval 'cf_cv_have_lib_'$1'=no'
576         cf_libdir=""
577         AC_CHECK_FUNC($5,
578                 eval 'cf_cv_have_lib_'$1'=yes',[
579                 cf_save_LIBS="$LIBS"
580                 AC_MSG_CHECKING(for $5 in -l$1)
581                 LIBS="-l$1 $LIBS"
582                 AC_TRY_LINK([$3],[$4],
583                         [AC_MSG_RESULT(yes)
584                          eval 'cf_cv_have_lib_'$1'=yes'
585                         ],
586                         [AC_MSG_RESULT(no)
587                         CF_LIBRARY_PATH(cf_search,$2)
588                         for cf_libdir in $cf_search
589                         do
590                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
591                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
592                                 AC_TRY_LINK([$3],[$4],
593                                         [AC_MSG_RESULT(yes)
594                                          eval 'cf_cv_have_lib_'$1'=yes'
595                                          break],
596                                         [AC_MSG_RESULT(no)
597                                          LIBS="$cf_save_LIBS"])
598                         done
599                         ])
600                 ])
601 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
602 ifelse($6,,[
603 if test $cf_found_library = no ; then
604         AC_ERROR(Cannot link $1 library)
605 fi
606 ])
607 ])dnl
608 dnl ---------------------------------------------------------------------------
609 dnl CF_FUNC_CURSES_VERSION version: 3 updated: 2003/05/17 22:19:02
610 dnl ----------------------
611 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
612 dnl It's a character string "SVR4", not documented.
613 AC_DEFUN([CF_FUNC_CURSES_VERSION],
614 [
615 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
616 AC_TRY_RUN([
617 #include <${cf_cv_ncurses_header-curses.h}>
618 int main()
619 {
620         char temp[1024];
621         sprintf(temp, "%s\n", curses_version());
622         exit(0);
623 }]
624 ,[cf_cv_func_curses_version=yes]
625 ,[cf_cv_func_curses_version=no]
626 ,[cf_cv_func_curses_version=unknown])
627 rm -f core])
628 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
629 ])
630 dnl ---------------------------------------------------------------------------
631 dnl CF_GCC_ATTRIBUTES version: 10 updated: 2005/05/28 13:16:28
632 dnl -----------------
633 dnl Test for availability of useful gcc __attribute__ directives to quiet
634 dnl compiler warnings.  Though useful, not all are supported -- and contrary
635 dnl to documentation, unrecognized directives cause older compilers to barf.
636 AC_DEFUN([CF_GCC_ATTRIBUTES],
637 [
638 if test "$GCC" = yes
639 then
640 cat > conftest.i <<EOF
641 #ifndef GCC_PRINTF
642 #define GCC_PRINTF 0
643 #endif
644 #ifndef GCC_SCANF
645 #define GCC_SCANF 0
646 #endif
647 #ifndef GCC_NORETURN
648 #define GCC_NORETURN /* nothing */
649 #endif
650 #ifndef GCC_UNUSED
651 #define GCC_UNUSED /* nothing */
652 #endif
653 EOF
654 if test "$GCC" = yes
655 then
656         AC_CHECKING([for $CC __attribute__ directives])
657 cat > conftest.$ac_ext <<EOF
658 #line __oline__ "configure"
659 #include "confdefs.h"
660 #include "conftest.h"
661 #include "conftest.i"
662 #if     GCC_PRINTF
663 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
664 #else
665 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
666 #endif
667 #if     GCC_SCANF
668 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
669 #else
670 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
671 #endif
672 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
673 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
674 extern void foo(void) GCC_NORETURN;
675 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
676 EOF
677         for cf_attribute in scanf printf unused noreturn
678         do
679                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
680                 cf_directive="__attribute__(($cf_attribute))"
681                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
682                 case $cf_attribute in
683                 scanf|printf)
684                 cat >conftest.h <<EOF
685 #define GCC_$cf_ATTRIBUTE 1
686 EOF
687                         ;;
688                 *)
689                 cat >conftest.h <<EOF
690 #define GCC_$cf_ATTRIBUTE $cf_directive
691 EOF
692                         ;;
693                 esac
694                 if AC_TRY_EVAL(ac_compile); then
695                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
696                         cat conftest.h >>confdefs.h
697                 fi
698         done
699 else
700         fgrep define conftest.i >>confdefs.h
701 fi
702 rm -rf conftest*
703 fi
704 ])dnl
705 dnl ---------------------------------------------------------------------------
706 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
707 dnl --------------
708 dnl Find version of gcc
709 AC_DEFUN([CF_GCC_VERSION],[
710 AC_REQUIRE([AC_PROG_CC])
711 GCC_VERSION=none
712 if test "$GCC" = yes ; then
713         AC_MSG_CHECKING(version of $CC)
714         GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
715         test -z "$GCC_VERSION" && GCC_VERSION=unknown
716         AC_MSG_RESULT($GCC_VERSION)
717 fi
718 ])dnl
719 dnl ---------------------------------------------------------------------------
720 dnl CF_GCC_WARNINGS version: 20 updated: 2005/08/06 18:37:29
721 dnl ---------------
722 dnl Check if the compiler supports useful warning options.  There's a few that
723 dnl we don't use, simply because they're too noisy:
724 dnl
725 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
726 dnl     -Wredundant-decls (system headers make this too noisy)
727 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
728 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
729 dnl             is enabled for ncurses using "--enable-const".
730 dnl     -pedantic
731 dnl
732 dnl Parameter:
733 dnl     $1 is an optional list of gcc warning flags that a particular
734 dnl             application might want to use, e.g., "no-unused" for
735 dnl             -Wno-unused
736 dnl Special:
737 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
738 dnl
739 AC_DEFUN([CF_GCC_WARNINGS],
740 [
741 AC_REQUIRE([CF_GCC_VERSION])
742 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
743
744 cat > conftest.$ac_ext <<EOF
745 #line __oline__ "configure"
746 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
747 EOF
748
749 if test "$INTEL_COMPILER" = yes
750 then
751 # The "-wdXXX" options suppress warnings:
752 # remark #1419: external declaration in primary source file
753 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
754 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
755 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
756 # remark #193: zero used for undefined preprocessing identifier
757 # remark #593: variable "curs_sb_left_arrow" was set but never used
758 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
759 # remark #869: parameter "tw" was never referenced
760 # remark #981: operands are evaluated in unspecified order
761 # warning #269: invalid format string conversion
762
763         AC_CHECKING([for $CC warning options])
764         cf_save_CFLAGS="$CFLAGS"
765         EXTRA_CFLAGS="-Wall"
766         for cf_opt in $1 \
767                 wd1419 \
768                 wd1682 \
769                 wd1683 \
770                 wd1684 \
771                 wd193 \
772                 wd279 \
773                 wd593 \
774                 wd810 \
775                 wd869 \
776                 wd981
777         do
778                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
779                 if AC_TRY_EVAL(ac_compile); then
780                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
781                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
782                 fi
783         done
784         CFLAGS="$cf_save_CFLAGS"
785
786 elif test "$GCC" = yes
787 then
788         AC_CHECKING([for $CC warning options])
789         cf_save_CFLAGS="$CFLAGS"
790         EXTRA_CFLAGS="-W -Wall"
791         cf_warn_CONST=""
792         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
793         for cf_opt in \
794                 Wbad-function-cast \
795                 Wcast-align \
796                 Wcast-qual \
797                 Winline \
798                 Wmissing-declarations \
799                 Wmissing-prototypes \
800                 Wnested-externs \
801                 Wpointer-arith \
802                 Wshadow \
803                 Wstrict-prototypes \
804                 Wundef $cf_warn_CONST $1
805         do
806                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
807                 if AC_TRY_EVAL(ac_compile); then
808                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
809                         case $cf_opt in #(vi
810                         Wcast-qual) #(vi
811                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
812                                 ;;
813                         Winline) #(vi
814                                 case $GCC_VERSION in
815                                 3.3*)
816                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
817                                         continue;;
818                                 esac
819                                 ;;
820                         esac
821                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
822                 fi
823         done
824         CFLAGS="$cf_save_CFLAGS"
825 fi
826 rm -f conftest*
827
828 AC_SUBST(EXTRA_CFLAGS)
829 ])dnl
830 dnl ---------------------------------------------------------------------------
831 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
832 dnl -------------
833 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
834 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
835 dnl (or misfeature) of glibc2, which breaks portability of many applications,
836 dnl since it is interwoven with GNU extensions.
837 dnl
838 dnl Well, yes we could work around it...
839 AC_DEFUN([CF_GNU_SOURCE],
840 [
841 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
842 AC_TRY_COMPILE([#include <sys/types.h>],[
843 #ifndef _XOPEN_SOURCE
844 make an error
845 #endif],
846         [cf_cv_gnu_source=no],
847         [cf_save="$CPPFLAGS"
848          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
849          AC_TRY_COMPILE([#include <sys/types.h>],[
850 #ifdef _XOPEN_SOURCE
851 make an error
852 #endif],
853         [cf_cv_gnu_source=no],
854         [cf_cv_gnu_source=yes])
855         CPPFLAGS="$cf_save"
856         ])
857 ])
858 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
859 ])dnl
860 dnl ---------------------------------------------------------------------------
861 dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
862 dnl --------------
863 dnl Construct a search-list for a nonstandard header-file
864 AC_DEFUN([CF_HEADER_PATH],
865 [CF_SUBDIR_PATH($1,$2,include)
866 test "$includedir" != NONE && \
867 test "$includedir" != "/usr/include" && \
868 test -d "$includedir" && {
869         test -d $includedir &&    $1="[$]$1 $includedir"
870         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
871 }
872
873 test "$oldincludedir" != NONE && \
874 test "$oldincludedir" != "/usr/include" && \
875 test -d "$oldincludedir" && {
876         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
877         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
878 }
879
880 ])dnl
881 dnl ---------------------------------------------------------------------------
882 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
883 dnl -----------------
884 dnl If we do not have a given script, look for it in the parent directory.
885 AC_DEFUN([CF_INHERIT_SCRIPT],
886 [
887 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
888 ])dnl
889 dnl ---------------------------------------------------------------------------
890 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
891 dnl -----------------
892 dnl Check if the given compiler is really the Intel compiler for Linux.  It
893 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
894 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
895 dnl
896 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
897 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
898 dnl the wrappers for gcc and g++ warnings.
899 dnl
900 dnl $1 = GCC (default) or GXX
901 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
902 dnl $3 = CFLAGS (default) or CXXFLAGS
903 AC_DEFUN([CF_INTEL_COMPILER],[
904 ifelse($2,,INTEL_COMPILER,[$2])=no
905
906 if test "$ifelse($1,,[$1],GCC)" = yes ; then
907         case $host_os in
908         linux*|gnu*)
909                 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
910                 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
911                 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
912                 AC_TRY_COMPILE([],[
913 #ifdef __INTEL_COMPILER
914 #else
915 make an error
916 #endif
917 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
918 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
919 ],[])
920                 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
921                 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
922                 ;;
923         esac
924 fi
925 ])dnl
926 dnl ---------------------------------------------------------------------------
927 dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
928 dnl ---------------
929 dnl Construct a search-list for a nonstandard library-file
930 AC_DEFUN([CF_LIBRARY_PATH],
931 [CF_SUBDIR_PATH($1,$2,lib)])dnl
932 dnl ---------------------------------------------------------------------------
933 dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
934 dnl ----------
935 dnl Write a debug message to config.log, along with the line number in the
936 dnl configure script.
937 AC_DEFUN([CF_MSG_LOG],[
938 echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
939 ])dnl
940 dnl ---------------------------------------------------------------------------
941 dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
942 dnl -------------------
943 dnl Check if we can compile with ncurses' header file
944 dnl $1 is the cache variable to set
945 dnl $2 is the header-file to include
946 dnl $3 is the root name (ncurses or ncursesw)
947 AC_DEFUN([CF_NCURSES_CC_CHECK],[
948         AC_TRY_COMPILE([
949 ]ifelse($3,ncursesw,[
950 #define _XOPEN_SOURCE_EXTENDED
951 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
952 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
953 ])[
954 #include <$2>],[
955 #ifdef NCURSES_VERSION
956 ]ifelse($3,ncursesw,[
957 #ifndef WACS_BSSB
958         make an error
959 #endif
960 ])[
961 printf("%s\n", NCURSES_VERSION);
962 #else
963 #ifdef __NCURSES_H
964 printf("old\n");
965 #else
966         make an error
967 #endif
968 #endif
969         ]
970         ,[$1=$cf_header]
971         ,[$1=no])
972 ])dnl
973 dnl ---------------------------------------------------------------------------
974 dnl CF_NCURSES_CPPFLAGS version: 18 updated: 2005/12/31 13:26:39
975 dnl -------------------
976 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
977 dnl the CPPFLAGS variable so we can include its header.
978 dnl
979 dnl The header files may be installed as either curses.h, or ncurses.h (would
980 dnl be obsolete, except that some packagers prefer this name to distinguish it
981 dnl from a "native" curses implementation).  If not installed for overwrite,
982 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
983 dnl /usr/include/ncurses), but someone may have installed overwriting the
984 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
985 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
986 dnl the header.
987 dnl
988 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
989 dnl is already in the include-path, don't even bother with this, since we cannot
990 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
991 dnl
992 dnl The optional parameter gives the root name of the library, in case it is
993 dnl not installed as the default curses library.  That is how the
994 dnl wide-character version of ncurses is installed.
995 AC_DEFUN([CF_NCURSES_CPPFLAGS],
996 [AC_REQUIRE([CF_WITH_CURSES_DIR])
997
998 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
999 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1000
1001 test -n "$cf_cv_curses_dir" && \
1002 test "$cf_cv_curses_dir" != "no" && \
1003 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
1004
1005 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1006         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1007         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1008         for cf_header in $cf_header_list
1009         do
1010                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1011                 test "$cf_cv_ncurses_h" != no && break
1012         done
1013 ])
1014
1015 CF_NCURSES_HEADER
1016 CF_TERM_HEADER
1017
1018 # some applications need this, but should check for NCURSES_VERSION
1019 AC_DEFINE(NCURSES)
1020
1021 CF_NCURSES_VERSION
1022 ])dnl
1023 dnl ---------------------------------------------------------------------------
1024 dnl CF_NCURSES_HEADER version: 1 updated: 2005/12/31 13:28:37
1025 dnl -----------------
1026 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1027 dnl variations of ncurses' installs.
1028 dnl
1029 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1030 AC_DEFUN([CF_NCURSES_HEADER],[
1031
1032 if test "$cf_cv_ncurses_h" != no ; then
1033         cf_cv_ncurses_header=$cf_cv_ncurses_h
1034 else
1035
1036 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1037         test -n "$verbose" && echo
1038         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1039         test -n "$verbose" && echo search path $cf_search
1040         cf_save2_CPPFLAGS="$CPPFLAGS"
1041         for cf_incdir in $cf_search
1042         do
1043                 CF_ADD_INCDIR($cf_incdir)
1044                 for cf_header in \
1045                         ncurses.h \
1046                         curses.h
1047                 do
1048                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1049                         if test "$cf_cv_ncurses_h2" != no ; then
1050                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1051                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
1052                                 break
1053                         fi
1054                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1055                 done
1056                 CPPFLAGS="$cf_save2_CPPFLAGS"
1057                 test "$cf_cv_ncurses_h2" != no && break
1058         done
1059         test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found)
1060         ])
1061
1062         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1063         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1064         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1065                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1066         fi
1067         CF_ADD_INCDIR($cf_1st_incdir)
1068
1069 fi
1070
1071 # Set definitions to allow ifdef'ing for ncurses.h
1072
1073 case $cf_cv_ncurses_header in # (vi
1074 *ncurses.h)
1075         AC_DEFINE(HAVE_NCURSES_H)
1076         ;;
1077 esac
1078
1079 case $cf_cv_ncurses_header in # (vi
1080 ncurses/curses.h|ncurses/ncurses.h)
1081         AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1082         ;;
1083 ncursesw/curses.h|ncursesw/ncurses.h)
1084         AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1085         ;;
1086 esac
1087
1088 ])dnl
1089 dnl ---------------------------------------------------------------------------
1090 dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05
1091 dnl ---------------
1092 dnl Look for the ncurses library.  This is a little complicated on Linux,
1093 dnl because it may be linked with the gpm (general purpose mouse) library.
1094 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1095 dnl unusable with ncurses.  However, we don't want to link with gpm unless
1096 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1097 dnl and the linker will record a dependency.
1098 dnl
1099 dnl The optional parameter gives the root name of the library, in case it is
1100 dnl not installed as the default curses library.  That is how the
1101 dnl wide-character version of ncurses is installed.
1102 AC_DEFUN([CF_NCURSES_LIBS],
1103 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1104
1105 cf_nculib_root=ifelse($1,,ncurses,$1)
1106         # This works, except for the special case where we find gpm, but
1107         # ncurses is in a nonstandard location via $LIBS, and we really want
1108         # to link gpm.
1109 cf_ncurses_LIBS=""
1110 cf_ncurses_SAVE="$LIBS"
1111 AC_CHECK_LIB(gpm,Gpm_Open,
1112         [AC_CHECK_LIB(gpm,initscr,
1113                 [LIBS="$cf_ncurses_SAVE"],
1114                 [cf_ncurses_LIBS="-lgpm"])])
1115
1116 case $host_os in #(vi
1117 freebsd*)
1118         # This is only necessary if you are linking against an obsolete
1119         # version of ncurses (but it should do no harm, since it's static).
1120         if test "$cf_nculib_root" = ncurses ; then
1121                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1122         fi
1123         ;;
1124 esac
1125
1126 LIBS="$cf_ncurses_LIBS $LIBS"
1127
1128 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1129 then
1130         LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
1131 else
1132         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1133                 [#include <${cf_cv_ncurses_header-curses.h}>],
1134                 [initscr()],
1135                 initscr)
1136 fi
1137
1138 if test -n "$cf_ncurses_LIBS" ; then
1139         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1140         cf_ncurses_SAVE="$LIBS"
1141         for p in $cf_ncurses_LIBS ; do
1142                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1143                 if test "$q" != "$LIBS" ; then
1144                         LIBS="$q"
1145                 fi
1146         done
1147         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1148                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1149                 [AC_MSG_RESULT(yes)],
1150                 [AC_MSG_RESULT(no)
1151                  LIBS="$cf_ncurses_SAVE"])
1152 fi
1153
1154 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1155 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1156 ])dnl
1157 dnl ---------------------------------------------------------------------------
1158 dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57
1159 dnl ------------------
1160 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1161 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
1162 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1163 AC_DEFUN([CF_NCURSES_VERSION],
1164 [
1165 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1166 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1167         cf_cv_ncurses_version=no
1168         cf_tempfile=out$$
1169         rm -f $cf_tempfile
1170         AC_TRY_RUN([
1171 #include <${cf_cv_ncurses_header-curses.h}>
1172 #include <stdio.h>
1173 int main()
1174 {
1175         FILE *fp = fopen("$cf_tempfile", "w");
1176 #ifdef NCURSES_VERSION
1177 # ifdef NCURSES_VERSION_PATCH
1178         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1179 # else
1180         fprintf(fp, "%s\n", NCURSES_VERSION);
1181 # endif
1182 #else
1183 # ifdef __NCURSES_H
1184         fprintf(fp, "old\n");
1185 # else
1186         make an error
1187 # endif
1188 #endif
1189         exit(0);
1190 }],[
1191         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1192
1193         # This will not work if the preprocessor splits the line after the
1194         # Autoconf token.  The 'unproto' program does that.
1195         cat > conftest.$ac_ext <<EOF
1196 #include <${cf_cv_ncurses_header-curses.h}>
1197 #undef Autoconf
1198 #ifdef NCURSES_VERSION
1199 Autoconf NCURSES_VERSION
1200 #else
1201 #ifdef __NCURSES_H
1202 Autoconf "old"
1203 #endif
1204 ;
1205 #endif
1206 EOF
1207         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1208         AC_TRY_EVAL(cf_try)
1209         if test -f conftest.out ; then
1210                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1211                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1212                 rm -f conftest.out
1213         fi
1214 ])
1215         rm -f $cf_tempfile
1216 ])
1217 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1218 ])dnl
1219 dnl ---------------------------------------------------------------------------
1220 dnl CF_PATH_SYNTAX version: 11 updated: 2006/09/02 08:55:46
1221 dnl --------------
1222 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1223 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1224 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1225 dnl delayed evaluation of those symbols.
1226 AC_DEFUN([CF_PATH_SYNTAX],[
1227 if test "x$prefix" != xNONE; then
1228   cf_path_syntax="$prefix"
1229 else
1230   cf_path_syntax="$ac_default_prefix"
1231 fi
1232
1233 case ".[$]$1" in #(vi
1234 .\[$]\(*\)*|.\'*\'*) #(vi
1235   ;;
1236 ..|./*|.\\*) #(vi
1237   ;;
1238 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1239   ;;
1240 .\[$]{*prefix}*) #(vi
1241   eval $1="[$]$1"
1242   case ".[$]$1" in #(vi
1243   .NONE/*)
1244     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1245     ;;
1246   esac
1247   ;; #(vi
1248 .no|.NONE/*)
1249   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1250   ;;
1251 *)
1252   ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1253   ;;
1254 esac
1255 ])dnl
1256 dnl ---------------------------------------------------------------------------
1257 dnl CF_PDCURSES_X11 version: 7 updated: 2006/11/12 17:31:59
1258 dnl ---------------
1259 dnl Configure for PDCurses' X11 library
1260 AC_DEFUN([CF_PDCURSES_X11],[
1261 AC_REQUIRE([CF_X_ATHENA])
1262
1263 AC_PATH_PROGS(XCURSES_CONFIG,xcurses-config,none)
1264
1265 if test "$XCURSES_CONFIG" != none ; then
1266
1267 CPPFLAGS="`$XCURSES_CONFIG --cflags` $CPPFLAGS"
1268 LIBS="`$XCURSES_CONFIG --libs` $LIBS"
1269
1270 cf_cv_lib_XCurses=yes
1271
1272 else
1273
1274 LDFLAGS="$LDFLAGS $X_LIBS"
1275 CF_CHECK_CFLAGS($X_CFLAGS)
1276 AC_CHECK_LIB(X11,XOpenDisplay,
1277         [LIBS="-lX11 $LIBS"],,
1278         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
1279 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
1280 LIBS="-lXCurses $LIBS"
1281 AC_TRY_LINK([
1282 #include <xcurses.h>
1283 char *XCursesProgramName = "test";
1284 ],[XCursesExit();],
1285 [cf_cv_lib_XCurses=yes],
1286 [cf_cv_lib_XCurses=no])
1287 ])
1288
1289 fi
1290
1291 if test $cf_cv_lib_XCurses = yes ; then
1292         AC_DEFINE(UNIX)
1293         AC_DEFINE(XCURSES)
1294         AC_DEFINE(HAVE_XCURSES)
1295 else
1296         AC_ERROR(Cannot link with XCurses)
1297 fi
1298 ])dnl
1299 dnl ---------------------------------------------------------------------------
1300 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1301 dnl -----------------
1302 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1303 dnl
1304 dnl     POSIX.1-1990                            _POSIX_SOURCE
1305 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
1306 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
1307 dnl             Bindings Option
1308 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
1309 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
1310 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
1311 dnl
1312 dnl Parameters:
1313 dnl     $1 is the nominal value for _POSIX_C_SOURCE
1314 AC_DEFUN([CF_POSIX_C_SOURCE],
1315 [
1316 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1317
1318 cf_save_CFLAGS="$CFLAGS"
1319 cf_save_CPPFLAGS="$CPPFLAGS"
1320
1321 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1322 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1323
1324 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1325         CF_MSG_LOG(if the symbol is already defined go no further)
1326         AC_TRY_COMPILE([#include <sys/types.h>],[
1327 #ifndef _POSIX_C_SOURCE
1328 make an error
1329 #endif],
1330         [cf_cv_posix_c_source=no],
1331         [cf_want_posix_source=no
1332          case .$cf_POSIX_C_SOURCE in #(vi
1333          .[[12]]??*) #(vi
1334                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1335                 ;;
1336          .2) #(vi
1337                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1338                 cf_want_posix_source=yes
1339                 ;;
1340          .*)
1341                 cf_want_posix_source=yes
1342                 ;;
1343          esac
1344          if test "$cf_want_posix_source" = yes ; then
1345                 AC_TRY_COMPILE([#include <sys/types.h>],[
1346 #ifdef _POSIX_SOURCE
1347 make an error
1348 #endif],[],
1349                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1350          fi
1351          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1352          CFLAGS="$cf_trim_CFLAGS"
1353          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1354          CF_MSG_LOG(if the second compile does not leave our definition intact error)
1355          AC_TRY_COMPILE([#include <sys/types.h>],[
1356 #ifndef _POSIX_C_SOURCE
1357 make an error
1358 #endif],,
1359          [cf_cv_posix_c_source=no])
1360          CFLAGS="$cf_save_CFLAGS"
1361          CPPFLAGS="$cf_save_CPPFLAGS"
1362         ])
1363 ])
1364
1365 if test "$cf_cv_posix_c_source" != no ; then
1366         CFLAGS="$cf_trim_CFLAGS"
1367         CPPFLAGS="$cf_trim_CPPFLAGS"
1368         if test "$cf_cv_cc_u_d_options" = yes ; then
1369                 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1370                                 sed -e 's/-D/-U/g' -e 's/=[[^   ]]*//g'`
1371                 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1372         fi
1373         CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1374 fi
1375
1376 ])dnl
1377 dnl ---------------------------------------------------------------------------
1378 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
1379 dnl ------------
1380 dnl Append definitions and rules for the given programs to the subdirectory
1381 dnl Makefiles, and the recursion rule for the top-level Makefile.
1382 dnl
1383 dnl parameters
1384 dnl     $1 = script to run
1385 dnl     $2 = list of subdirectories
1386 dnl
1387 dnl variables
1388 dnl     $AWK
1389 AC_DEFUN([CF_PRG_RULES],
1390 [
1391 for cf_dir in $2
1392 do
1393         if test ! -d $srcdir/$cf_dir; then
1394                 continue
1395         elif test -f $srcdir/$cf_dir/programs; then
1396                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
1397         fi
1398 done
1399
1400 ])dnl
1401 dnl ---------------------------------------------------------------------------
1402 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1403 dnl --------------
1404 dnl Check if C (preprocessor) -U and -D options are processed in the order
1405 dnl given rather than by type of option.  Some compilers insist on apply all
1406 dnl of the -U options after all of the -D options.  Others allow mixing them,
1407 dnl and may predefine symbols that conflict with those we define.
1408 AC_DEFUN([CF_PROG_CC_U_D],
1409 [
1410 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1411         cf_save_CPPFLAGS="$CPPFLAGS"
1412         CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1413         AC_TRY_COMPILE([],[
1414 #ifndef U_D_OPTIONS
1415 make an undefined-error
1416 #endif
1417 #ifdef  D_U_OPTIONS
1418 make a defined-error
1419 #endif
1420         ],[
1421         cf_cv_cc_u_d_options=yes],[
1422         cf_cv_cc_u_d_options=no])
1423         CPPFLAGS="$cf_save_CPPFLAGS"
1424 ])
1425 ])dnl
1426 dnl ---------------------------------------------------------------------------
1427 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1428 dnl ----------------
1429 dnl Remove all -U and -D options that refer to the given symbol from a list
1430 dnl of C compiler options.  This works around the problem that not all
1431 dnl compilers process -U and -D options from left-to-right, so a -U option
1432 dnl cannot be used to cancel the effect of a preceding -D option.
1433 dnl
1434 dnl $1 = target (which could be the same as the source variable)
1435 dnl $2 = source (including '$')
1436 dnl $3 = symbol to remove
1437 define([CF_REMOVE_DEFINE],
1438 [
1439 # remove $3 symbol from $2
1440 $1=`echo "$2" | \
1441         sed     -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[[       ]]/ /g' \
1442                 -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[$]//g'`
1443 ])dnl
1444 dnl ---------------------------------------------------------------------------
1445 dnl CF_SUBDIR_PATH version: 4 updated: 2006/11/18 17:13:19
1446 dnl --------------
1447 dnl Construct a search-list for a nonstandard header/lib-file
1448 dnl     $1 = the variable to return as result
1449 dnl     $2 = the package name
1450 dnl     $3 = the subdirectory, e.g., bin, include or lib
1451 AC_DEFUN([CF_SUBDIR_PATH],
1452 [$1=""
1453
1454 test -d "[$]HOME" && {
1455         test -n "$verbose" && echo "    ... testing $3-directories under [$]HOME"
1456         test -d "[$]HOME/$3" &&          $1="[$]$1 [$]HOME/$3"
1457         test -d "[$]HOME/$3/$2" &&       $1="[$]$1 [$]HOME/$3/$2"
1458         test -d "[$]HOME/$3/$2/$3" &&    $1="[$]$1 [$]HOME/$3/$2/$3"
1459 }
1460
1461 # For other stuff under the home directory, it should be sufficient to put
1462 # a symbolic link for $HOME/$2 to the actual package location:
1463 test -d "[$]HOME/$2" && {
1464         test -n "$verbose" && echo "    ... testing $3-directories under [$]HOME/$2"
1465         test -d "[$]HOME/$2/$3" &&       $1="[$]$1 [$]HOME/$2/$3"
1466         test -d "[$]HOME/$2/$3/$2" &&    $1="[$]$1 [$]HOME/$2/$3/$2"
1467 }
1468
1469 test "$prefix" != /usr/local && \
1470 test -d /usr/local && {
1471         test -n "$verbose" && echo "    ... testing $3-directories under /usr/local"
1472         test -d /usr/local/$3 &&       $1="[$]$1 /usr/local/$3"
1473         test -d /usr/local/$3/$2 &&    $1="[$]$1 /usr/local/$3/$2"
1474         test -d /usr/local/$3/$2/$3 && $1="[$]$1 /usr/local/$3/$2/$3"
1475         test -d /usr/local/$2/$3 &&    $1="[$]$1 /usr/local/$2/$3"
1476         test -d /usr/local/$2/$3/$2 && $1="[$]$1 /usr/local/$2/$3/$2"
1477 }
1478
1479 test "$prefix" != NONE && \
1480 test -d $prefix && {
1481         test -n "$verbose" && echo "    ... testing $3-directories under $prefix"
1482         test -d $prefix/$3 &&          $1="[$]$1 $prefix/$3"
1483         test -d $prefix/$3/$2 &&       $1="[$]$1 $prefix/$3/$2"
1484         test -d $prefix/$3/$2/$3 &&    $1="[$]$1 $prefix/$3/$2/$3"
1485         test -d $prefix/$2/$3 &&       $1="[$]$1 $prefix/$2/$3"
1486         test -d $prefix/$2/$3/$2 &&    $1="[$]$1 $prefix/$2/$3/$2"
1487 }
1488
1489 test "$prefix" != /opt && \
1490 test -d /opt && {
1491         test -n "$verbose" && echo "    ... testing $3-directories under /opt"
1492         test -d /opt/$3 &&             $1="[$]$1 /opt/$3"
1493         test -d /opt/$3/$2 &&          $1="[$]$1 /opt/$3/$2"
1494         test -d /opt/$3/$2/$3 &&       $1="[$]$1 /opt/$3/$2/$3"
1495         test -d /opt/$2/$3 &&          $1="[$]$1 /opt/$2/$3"
1496         test -d /opt/$2/$3/$2 &&       $1="[$]$1 /opt/$2/$3/$2"
1497 }
1498
1499 test "$prefix" != /usr && \
1500 test -d /usr && {
1501         test -n "$verbose" && echo "    ... testing $3-directories under /usr"
1502         test -d /usr/$3 &&             $1="[$]$1 /usr/$3"
1503         test -d /usr/$3/$2 &&          $1="[$]$1 /usr/$3/$2"
1504         test -d /usr/$3/$2/$3 &&       $1="[$]$1 /usr/$3/$2/$3"
1505         test -d /usr/$2/$3 &&          $1="[$]$1 /usr/$2/$3"
1506 }
1507 ])dnl
1508 dnl ---------------------------------------------------------------------------
1509 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1510 dnl ------------------
1511 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1512 dnl older SCO configurations.
1513 AC_DEFUN([CF_SYS_TIME_SELECT],
1514 [
1515 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1516 AC_CACHE_VAL(cf_cv_sys_time_select,[
1517 AC_TRY_COMPILE([
1518 #include <sys/types.h>
1519 #ifdef HAVE_SYS_TIME_H
1520 #include <sys/time.h>
1521 #endif
1522 #ifdef HAVE_SYS_SELECT_H
1523 #include <sys/select.h>
1524 #endif
1525 ],[],[cf_cv_sys_time_select=yes],
1526      [cf_cv_sys_time_select=no])
1527      ])
1528 AC_MSG_RESULT($cf_cv_sys_time_select)
1529 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1530 ])dnl
1531 dnl ---------------------------------------------------------------------------
1532 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
1533 dnl --------------
1534 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
1535 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
1536 dnl but some packagers change this, breaking various applications.
1537 AC_DEFUN([CF_TERM_HEADER],[
1538 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
1539 case ${cf_cv_ncurses_header} in #(vi
1540 */ncurses.h|*/ncursesw.h) #(vi
1541         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
1542         ;;
1543 *)
1544         cf_term_header=term.h
1545         ;;
1546 esac
1547
1548 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
1549 do
1550 AC_TRY_COMPILE([#include <stdio.h>
1551 #include <${cf_cv_ncurses_header-curses.h}>
1552 #include <$cf_test>
1553 ],[int x = auto_left_margin],[
1554         cf_cv_term_header="$cf_test"],[
1555         cf_cv_term_header=unknown
1556         ])
1557         test "$cf_cv_term_header" != unknown && break
1558 done
1559 ])
1560
1561 # Set definitions to allow ifdef'ing to accommodate subdirectories
1562
1563 case $cf_cv_term_header in # (vi
1564 *term.h)
1565         AC_DEFINE(HAVE_TERM_H)
1566         ;;
1567 esac
1568
1569 case $cf_cv_term_header in # (vi
1570 ncurses/term.h) #(vi
1571         AC_DEFINE(HAVE_NCURSES_TERM_H)
1572         ;;
1573 ncursesw/term.h)
1574         AC_DEFINE(HAVE_NCURSESW_TERM_H)
1575         ;;
1576 esac
1577 ])dnl
1578 dnl ---------------------------------------------------------------------------
1579 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1580 dnl --------
1581 dnl Make an uppercase version of a variable
1582 dnl $1=uppercase($2)
1583 AC_DEFUN([CF_UPPER],
1584 [
1585 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1586 ])dnl
1587 dnl ---------------------------------------------------------------------------
1588 dnl CF_UTF8_LIB version: 4 updated: 2003/03/01 18:36:42
1589 dnl -----------
1590 dnl Check for multibyte support, and if not found, utf8 compatibility library
1591 AC_DEFUN([CF_UTF8_LIB],
1592 [
1593 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
1594         cf_save_LIBS="$LIBS"
1595         AC_TRY_LINK([
1596 #include <stdlib.h>],[putwc(0,0);],
1597         [cf_cv_utf8_lib=yes],
1598         [LIBS="-lutf8 $LIBS"
1599          AC_TRY_LINK([
1600 #include <libutf8.h>],[putwc(0,0);],
1601                 [cf_cv_utf8_lib=add-on],
1602                 [cf_cv_utf8_lib=no])
1603         LIBS="$cf_save_LIBS"
1604 ])])
1605
1606 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
1607 # ncurses/ncursesw:
1608 if test "$cf_cv_utf8_lib" = "add-on" ; then
1609         AC_DEFINE(HAVE_LIBUTF8_H)
1610         LIBS="-lutf8 $LIBS"
1611 fi
1612 ])dnl
1613 dnl ---------------------------------------------------------------------------
1614 dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
1615 dnl ----------
1616 dnl Use AC_VERBOSE w/o the warnings
1617 AC_DEFUN([CF_VERBOSE],
1618 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
1619 ])dnl
1620 dnl ---------------------------------------------------------------------------
1621 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
1622 dnl ------------------
1623 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
1624 dnl libraries.
1625 AC_DEFUN([CF_WITH_CURSES_DIR],[
1626 AC_ARG_WITH(curses-dir,
1627         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
1628         [CF_PATH_SYNTAX(withval)
1629          cf_cv_curses_dir=$withval],
1630         [cf_cv_curses_dir=no])
1631 ])dnl
1632 dnl ---------------------------------------------------------------------------
1633 dnl CF_XOPEN_SOURCE version: 24 updated: 2006/04/02 16:41:09
1634 dnl ---------------
1635 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1636 dnl or adapt to the vendor's definitions to get equivalent functionality,
1637 dnl without losing the common non-POSIX features.
1638 dnl
1639 dnl Parameters:
1640 dnl     $1 is the nominal value for _XOPEN_SOURCE
1641 dnl     $2 is the nominal value for _POSIX_C_SOURCE
1642 AC_DEFUN([CF_XOPEN_SOURCE],[
1643
1644 AC_REQUIRE([CF_PROG_CC_U_D])
1645
1646 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
1647 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
1648
1649 case $host_os in #(vi
1650 aix[[45]]*) #(vi
1651         CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
1652         ;;
1653 freebsd*) #(vi
1654         # 5.x headers associate
1655         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1656         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1657         cf_POSIX_C_SOURCE=200112L
1658         cf_XOPEN_SOURCE=600
1659         CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1660         ;;
1661 hpux*) #(vi
1662         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
1663         ;;
1664 irix[[56]].*) #(vi
1665         CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
1666         ;;
1667 linux*|gnu*) #(vi
1668         CF_GNU_SOURCE
1669         ;;
1670 mirbsd*) #(vi
1671         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
1672         ;;
1673 netbsd*) #(vi
1674         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1675         ;;
1676 openbsd*) #(vi
1677         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1678         ;;
1679 osf[[45]]*) #(vi
1680         CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
1681         ;;
1682 nto-qnx*) #(vi
1683         CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
1684         ;;
1685 sco*) #(vi
1686         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1687         ;;
1688 solaris*) #(vi
1689         CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1690         ;;
1691 *)
1692         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1693         AC_TRY_COMPILE([#include <sys/types.h>],[
1694 #ifndef _XOPEN_SOURCE
1695 make an error
1696 #endif],
1697         [cf_cv_xopen_source=no],
1698         [cf_save="$CPPFLAGS"
1699          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1700          AC_TRY_COMPILE([#include <sys/types.h>],[
1701 #ifdef _XOPEN_SOURCE
1702 make an error
1703 #endif],
1704         [cf_cv_xopen_source=no],
1705         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1706         CPPFLAGS="$cf_save"
1707         ])
1708 ])
1709         if test "$cf_cv_xopen_source" != no ; then
1710                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1711                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1712                 test "$cf_cv_cc_u_d_options" = yes && \
1713                         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
1714                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
1715         fi
1716         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1717         ;;
1718 esac
1719 ])
1720 dnl ---------------------------------------------------------------------------
1721 dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41
1722 dnl -----------
1723 dnl Check for Xaw (Athena) libraries
1724 dnl
1725 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
1726 AC_DEFUN([CF_X_ATHENA],
1727 [AC_REQUIRE([CF_X_TOOLKIT])
1728 cf_x_athena=${cf_x_athena-Xaw}
1729
1730 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
1731 withval=
1732 AC_ARG_WITH(Xaw3d,
1733         [  --with-Xaw3d            link with Xaw 3d library])
1734 if test "$withval" = yes ; then
1735         cf_x_athena=Xaw3d
1736         AC_MSG_RESULT(yes)
1737 else
1738         AC_MSG_RESULT(no)
1739 fi
1740
1741 AC_MSG_CHECKING(if you want to link with neXT Athena library)
1742 withval=
1743 AC_ARG_WITH(neXtaw,
1744         [  --with-neXtaw           link with neXT Athena library])
1745 if test "$withval" = yes ; then
1746         cf_x_athena=neXtaw
1747         AC_MSG_RESULT(yes)
1748 else
1749         AC_MSG_RESULT(no)
1750 fi
1751
1752 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
1753 withval=
1754 AC_ARG_WITH(XawPlus,
1755         [  --with-XawPlus          link with Athena-Plus library])
1756 if test "$withval" = yes ; then
1757         cf_x_athena=XawPlus
1758         AC_MSG_RESULT(yes)
1759 else
1760         AC_MSG_RESULT(no)
1761 fi
1762
1763 AC_CHECK_LIB(Xext,XextCreateExtension,
1764         [LIBS="-lXext $LIBS"])
1765
1766 cf_x_athena_lib=""
1767
1768 CF_X_ATHENA_CPPFLAGS($cf_x_athena)
1769 CF_X_ATHENA_LIBS($cf_x_athena)
1770 ])dnl
1771 dnl ---------------------------------------------------------------------------
1772 dnl CF_X_ATHENA_CPPFLAGS version: 2 updated: 2002/10/09 20:00:37
1773 dnl --------------------
1774 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
1775 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
1776 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
1777 [
1778 cf_x_athena_root=ifelse($1,,Xaw,$1)
1779 cf_x_athena_include=""
1780
1781 for cf_path in default \
1782         /usr/contrib/X11R6 \
1783         /usr/contrib/X11R5 \
1784         /usr/lib/X11R5 \
1785         /usr/local
1786 do
1787         if test -z "$cf_x_athena_include" ; then
1788                 cf_save="$CPPFLAGS"
1789                 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
1790                 if test $cf_path != default ; then
1791                         CPPFLAGS="-I$cf_path/include $cf_save"
1792                         AC_MSG_CHECKING(for $cf_test in $cf_path)
1793                 else
1794                         AC_MSG_CHECKING(for $cf_test)
1795                 fi
1796                 AC_TRY_COMPILE([
1797 #include <X11/Intrinsic.h>
1798 #include <$cf_test>],[],
1799                         [cf_result=yes],
1800                         [cf_result=no])
1801                 AC_MSG_RESULT($cf_result)
1802                 if test "$cf_result" = yes ; then
1803                         cf_x_athena_include=$cf_path
1804                         break
1805                 else
1806                         CPPFLAGS="$cf_save"
1807                 fi
1808         fi
1809 done
1810
1811 if test -z "$cf_x_athena_include" ; then
1812         AC_MSG_WARN(
1813 [Unable to successfully find Athena header files with test program])
1814 elif test "$cf_x_athena_include" != default ; then
1815         CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include"
1816 fi
1817 ])
1818 dnl ---------------------------------------------------------------------------
1819 dnl CF_X_ATHENA_LIBS version: 6 updated: 2006/11/30 17:57:11
1820 dnl ----------------
1821 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
1822 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
1823 AC_DEFUN([CF_X_ATHENA_LIBS],
1824 [AC_REQUIRE([CF_X_TOOLKIT])
1825 cf_x_athena_root=ifelse($1,,Xaw,$1)
1826 cf_x_athena_lib=""
1827
1828 for cf_path in default \
1829         /usr/contrib/X11R6 \
1830         /usr/contrib/X11R5 \
1831         /usr/lib/X11R5 \
1832         /usr/local
1833 do
1834         for cf_lib in \
1835                 "-l$cf_x_athena_root -lXmu" \
1836                 "-l$cf_x_athena_root -lXpm -lXmu" \
1837                 "-l${cf_x_athena_root}_s -lXmu_s"
1838         do
1839                 if test -z "$cf_x_athena_lib" ; then
1840                         cf_save="$LIBS"
1841                         cf_test=XawSimpleMenuAddGlobalActions
1842                         if test $cf_path != default ; then
1843                                 LIBS="-L$cf_path/lib $cf_lib $LIBS"
1844                                 AC_MSG_CHECKING(for $cf_lib in $cf_path)
1845                         else
1846                                 LIBS="$cf_lib $LIBS"
1847                                 AC_MSG_CHECKING(for $cf_test in $cf_lib)
1848                         fi
1849                         AC_TRY_LINK([],[$cf_test()],
1850                                 [cf_result=yes],
1851                                 [cf_result=no])
1852                         AC_MSG_RESULT($cf_result)
1853                         if test "$cf_result" = yes ; then
1854                                 cf_x_athena_lib="$cf_lib"
1855                                 break
1856                         fi
1857                         LIBS="$cf_save"
1858                 fi
1859         done
1860 done
1861
1862 if test -z "$cf_x_athena_lib" ; then
1863         AC_ERROR(
1864 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
1865 fi
1866
1867 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
1868 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
1869 ])
1870 dnl ---------------------------------------------------------------------------
1871 dnl CF_X_TOOLKIT version: 11 updated: 2006/11/29 19:05:14
1872 dnl ------------
1873 dnl Check for X Toolkit libraries
1874 dnl
1875 AC_DEFUN([CF_X_TOOLKIT],
1876 [
1877 AC_REQUIRE([AC_PATH_XTRA])
1878 AC_REQUIRE([CF_CHECK_CACHE])
1879
1880 # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
1881
1882 cf_have_X_LIBS=no
1883
1884 LDFLAGS="$X_LIBS $LDFLAGS"
1885 CF_CHECK_CFLAGS($X_CFLAGS)
1886
1887 AC_CHECK_FUNC(XOpenDisplay,,[
1888 AC_CHECK_LIB(X11,XOpenDisplay,
1889         [LIBS="-lX11 $LIBS"],,
1890         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
1891
1892 AC_CHECK_FUNC(XtAppInitialize,,[
1893 AC_CHECK_LIB(Xt, XtAppInitialize,
1894         [AC_DEFINE(HAVE_LIBXT)
1895          cf_have_X_LIBS=Xt
1896          LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
1897         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
1898
1899 if test $cf_have_X_LIBS = no ; then
1900         AC_WARN(
1901 [Unable to successfully link X Toolkit library (-lXt) with
1902 test program.  You will have to check and add the proper libraries by hand
1903 to makefile.])
1904 fi
1905 ])dnl