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