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