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