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