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