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