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