]> ncurses.scripts.mit.edu Git - ncurses.git/blob - tack/aclocal.m4
ncurses 5.6 - patch 20070128
[ncurses.git] / tack / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2007 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.2 2007/01/13 23:57:11 tom Exp $
30 dnl
31 dnl Author: Thomas E. Dickey
32 dnl
33 dnl Macros used in TACK test program auto-configuration script.
34 dnl
35 dnl These macros are maintained separately from NCURSES.  The copyright on
36 dnl this file applies to the aggregation of macros and does not affect use of
37 dnl these macros in other applications.
38 dnl
39 dnl See http://invisible-island.net/autoconf/ for additional information.
40 dnl
41 dnl ---------------------------------------------------------------------------
42 dnl ---------------------------------------------------------------------------
43 dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
44 dnl -------------
45 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
46 dnl The second parameter if given makes this macro verbose.
47 dnl
48 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
49 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
50 dnl confused by the quotes (which require backslashes to keep them usable).
51 AC_DEFUN([CF_ADD_CFLAGS],
52 [
53 cf_fix_cppflags=no
54 cf_new_cflags=
55 cf_new_cppflags=
56 cf_new_extra_cppflags=
57
58 for cf_add_cflags in $1
59 do
60 case $cf_fix_cppflags in
61 no)
62         case $cf_add_cflags in #(vi
63         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
64                 case $cf_add_cflags in
65                 -D*)
66                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
67
68                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
69                         && test -z "${cf_tst_cflags}" \
70                         && cf_fix_cppflags=yes
71
72                         if test $cf_fix_cppflags = yes ; then
73                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
74                                 continue
75                         elif test "${cf_tst_cflags}" = "\"'" ; then
76                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
77                                 continue
78                         fi
79                         ;;
80                 esac
81                 case "$CPPFLAGS" in
82                 *$cf_add_cflags) #(vi
83                         ;;
84                 *) #(vi
85                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
86                         ;;
87                 esac
88                 ;;
89         *)
90                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
91                 ;;
92         esac
93         ;;
94 yes)
95         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
96
97         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
98
99         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
100         && test -z "${cf_tst_cflags}" \
101         && cf_fix_cppflags=no
102         ;;
103 esac
104 done
105
106 if test -n "$cf_new_cflags" ; then
107         ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
108         CFLAGS="$CFLAGS $cf_new_cflags"
109 fi
110
111 if test -n "$cf_new_cppflags" ; then
112         ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
113         CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
114 fi
115
116 if test -n "$cf_new_extra_cppflags" ; then
117         ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
118         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
119 fi
120
121 AC_SUBST(EXTRA_CPPFLAGS)
122
123 ])dnl
124 dnl ---------------------------------------------------------------------------
125 dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52
126 dnl -------------
127 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
128 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
129 dnl but old versions (and some misinstalled ones) need that.  To make things
130 dnl worse, gcc 3.x gives error messages if -I/usr/local/include is added to
131 dnl the include-path).
132 AC_DEFUN([CF_ADD_INCDIR],
133 [
134 for cf_add_incdir in $1
135 do
136         while true
137         do
138                 case $cf_add_incdir in
139                 /usr/include) # (vi
140                         ;;
141                 /usr/local/include) # (vi
142                         if test "$GCC" = yes
143                         then
144                                 cf_save_CPPFLAGS="$CPPFLAGS"
145                                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
146                                 AC_TRY_COMPILE([#include <stdio.h>],
147                                                 [printf("Hello")],
148                                                 [],
149                                                 [CPPFLAGS="$cf_save_CPPFLAGS"])
150                         fi
151                         ;;
152                 *) # (vi
153                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
154                         ;;
155                 esac
156                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
157                 test "$cf_top_incdir" = "$cf_add_incdir" && break
158                 cf_add_incdir="$cf_top_incdir"
159         done
160 done
161 ])dnl
162 dnl ---------------------------------------------------------------------------
163 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
164 dnl ----------------
165 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
166 dnl in the sharutils 4.2 distribution.
167 AC_DEFUN([CF_ANSI_CC_CHECK],
168 [
169 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
170 cf_cv_ansi_cc=no
171 cf_save_CFLAGS="$CFLAGS"
172 cf_save_CPPFLAGS="$CPPFLAGS"
173 # Don't try gcc -ansi; that turns off useful extensions and
174 # breaks some systems' header files.
175 # AIX                   -qlanglvl=ansi
176 # Ultrix and OSF/1      -std1
177 # HP-UX                 -Aa -D_HPUX_SOURCE
178 # SVR4                  -Xc
179 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
180 for cf_arg in "-DCC_HAS_PROTOS" \
181         "" \
182         -qlanglvl=ansi \
183         -std1 \
184         -Ae \
185         "-Aa -D_HPUX_SOURCE" \
186         -Xc
187 do
188         CF_ADD_CFLAGS($cf_arg)
189         AC_TRY_COMPILE(
190 [
191 #ifndef CC_HAS_PROTOS
192 #if !defined(__STDC__) || (__STDC__ != 1)
193 choke me
194 #endif
195 #endif
196 ],[
197         int test (int i, double x);
198         struct s1 {int (*f) (int a);};
199         struct s2 {int (*f) (double a);};],
200         [cf_cv_ansi_cc="$cf_arg"; break])
201 done
202 CFLAGS="$cf_save_CFLAGS"
203 CPPFLAGS="$cf_save_CPPFLAGS"
204 ])
205
206 if test "$cf_cv_ansi_cc" != "no"; then
207 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
208         CF_ADD_CFLAGS($cf_cv_ansi_cc)
209 else
210         AC_DEFINE(CC_HAS_PROTOS)
211 fi
212 fi
213 ])dnl
214 dnl ---------------------------------------------------------------------------
215 dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
216 dnl ---------------
217 dnl For programs that must use an ANSI compiler, obtain compiler options that
218 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
219 dnl macros, since tools such as unproto can fake prototypes, but only part of
220 dnl the preprocessor.
221 AC_DEFUN([CF_ANSI_CC_REQD],
222 [AC_REQUIRE([CF_ANSI_CC_CHECK])
223 if test "$cf_cv_ansi_cc" = "no"; then
224         AC_ERROR(
225 [Your compiler does not appear to recognize prototypes.
226 You have the following choices:
227         a. adjust your compiler options
228         b. get an up-to-date compiler
229         c. use a wrapper such as unproto])
230 fi
231 ])dnl
232 dnl ---------------------------------------------------------------------------
233 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
234 dnl -------------
235 dnl Allow user to enable a normally-off option.
236 AC_DEFUN([CF_ARG_ENABLE],
237 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
238 dnl ---------------------------------------------------------------------------
239 dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
240 dnl -------------
241 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
242 dnl values.
243 dnl
244 dnl Parameters:
245 dnl $1 = option name
246 dnl $2 = help-string
247 dnl $3 = action to perform if option is not default
248 dnl $4 = action if perform if option is default
249 dnl $5 = default option value (either 'yes' or 'no')
250 AC_DEFUN([CF_ARG_OPTION],
251 [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
252   if test "$enableval" != "$5" ; then
253 ifelse($3,,[    :]dnl
254 ,[    $3]) ifelse($4,,,[
255   else
256     $4])
257   fi],[enableval=$5 ifelse($4,,,[
258   $4
259 ])dnl
260   ])])dnl
261 dnl ---------------------------------------------------------------------------
262 dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
263 dnl --------------
264 dnl Check if we're accidentally using a cache from a different machine.
265 dnl Derive the system name, as a check for reusing the autoconf cache.
266 dnl
267 dnl If we've packaged config.guess and config.sub, run that (since it does a
268 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
269 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
270 dnl which is useful in cross-compiles.
271 dnl
272 dnl Note: we would use $ac_config_sub, but that is one of the places where
273 dnl autoconf 2.5x broke compatibility with autoconf 2.13
274 AC_DEFUN([CF_CHECK_CACHE],
275 [
276 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
277         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
278         system_name="$host_os"
279 else
280         system_name="`(uname -s -r) 2>/dev/null`"
281         if test -z "$system_name" ; then
282                 system_name="`(hostname) 2>/dev/null`"
283         fi
284 fi
285 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
286 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
287
288 test -z "$system_name" && system_name="$cf_cv_system_name"
289 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
290
291 if test ".$system_name" != ".$cf_cv_system_name" ; then
292         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
293         AC_ERROR("Please remove config.cache and try again.")
294 fi
295 ])dnl
296 dnl ---------------------------------------------------------------------------
297 dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
298 dnl ---------------
299 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
300 dnl a build-configuration such as imake.  These have the pitfall that they
301 dnl often contain compiler-specific options which we cannot use, mixed with
302 dnl preprocessor options that we usually can.
303 AC_DEFUN([CF_CHECK_CFLAGS],
304 [
305 CF_VERBOSE(checking additions to CFLAGS)
306 cf_check_cflags="$CFLAGS"
307 cf_check_cppflags="$CPPFLAGS"
308 CF_ADD_CFLAGS($1,yes)
309 if test "$cf_check_cflags" != "$CFLAGS" ; then
310 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
311         [CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
312          if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
313                  CF_VERBOSE(but keeping change to \$CPPFLAGS)
314          fi
315          CFLAGS="$cf_check_flags"])
316 fi
317 ])dnl
318 dnl ---------------------------------------------------------------------------
319 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
320 dnl ----------------
321 dnl Tie together the configure-script macros for curses.  It may be ncurses,
322 dnl but unless asked, we do not make a special search for ncurses.  However,
323 dnl still check for the ncurses version number, for use in other macros.
324 AC_DEFUN([CF_CURSES_CONFIG],
325 [
326 CF_CURSES_CPPFLAGS
327 CF_NCURSES_VERSION
328 CF_CURSES_LIBS
329 ])dnl
330 dnl ---------------------------------------------------------------------------
331 dnl CF_CURSES_CPPFLAGS version: 9 updated: 2006/02/04 19:44:43
332 dnl ------------------
333 dnl Look for the curses headers.
334 AC_DEFUN([CF_CURSES_CPPFLAGS],[
335
336 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
337 cf_cv_curses_incdir=no
338 case $host_os in #(vi
339 hpux10.*) #(vi
340         test -d /usr/include/curses_colr && \
341         cf_cv_curses_incdir="-I/usr/include/curses_colr"
342         ;;
343 sunos3*|sunos4*)
344         test -d /usr/5lib && \
345         test -d /usr/5include && \
346         cf_cv_curses_incdir="-I/usr/5include"
347         ;;
348 esac
349 ])
350 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
351
352 CF_CURSES_HEADER
353 CF_TERM_HEADER
354 ])dnl
355 dnl ---------------------------------------------------------------------------
356 dnl CF_CURSES_HEADER version: 1 updated: 2005/12/31 13:28:25
357 dnl ----------------
358 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
359 dnl variations of ncurses' installs.
360 dnl
361 dnl See also CF_NCURSES_HEADER, which sets the same cache variable.
362 AC_DEFUN([CF_CURSES_HEADER],[
363 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
364 cf_cv_ncurses_header=none
365 for cf_header in \
366         curses.h \
367         ncurses.h \
368         ncurses/curses.h \
369         ncurses/ncurses.h
370 do
371 AC_TRY_COMPILE([#include <${cf_header}>],
372         [initscr(); tgoto("?", 0,0)],
373         [cf_cv_ncurses_header=$cf_header; break],[])
374 done
375 ])
376
377 if test "$cf_cv_ncurses_header" = none ; then
378         AC_MSG_ERROR(No curses header-files found)
379 fi
380
381 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
382 AC_CHECK_HEADERS($cf_cv_ncurses_header)
383 ])dnl
384 dnl ---------------------------------------------------------------------------
385 dnl CF_CURSES_LIBS version: 24 updated: 2006/02/04 19:44:43
386 dnl --------------
387 dnl Look for the curses libraries.  Older curses implementations may require
388 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
389 AC_DEFUN([CF_CURSES_LIBS],[
390
391 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
392 AC_MSG_CHECKING(if we have identified curses libraries)
393 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
394         [initscr(); tgoto("?", 0,0)],
395         cf_result=yes,
396         cf_result=no)
397 AC_MSG_RESULT($cf_result)
398
399 if test "$cf_result" = no ; then
400 case $host_os in #(vi
401 freebsd*) #(vi
402         AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
403         ;;
404 hpux10.*) #(vi
405         AC_CHECK_LIB(cur_colr,initscr,[
406                 LIBS="-lcur_colr $LIBS"
407                 ac_cv_func_initscr=yes
408                 ],[
409         AC_CHECK_LIB(Hcurses,initscr,[
410                 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
411                 LIBS="-lHcurses $LIBS"
412                 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
413                 ac_cv_func_initscr=yes
414                 ])])
415         ;;
416 linux*) # Suse Linux does not follow /usr/lib convention
417         LIBS="$LIBS -L/lib"
418         ;;
419 sunos3*|sunos4*)
420         test -d /usr/5lib && \
421         LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap"
422         ac_cv_func_initscr=yes
423         ;;
424 esac
425
426 if test ".$ac_cv_func_initscr" != .yes ; then
427         cf_save_LIBS="$LIBS"
428         cf_term_lib=""
429         cf_curs_lib=""
430
431         if test ".${cf_cv_ncurses_version-no}" != .no
432         then
433                 cf_check_list="ncurses curses cursesX"
434         else
435                 cf_check_list="cursesX curses ncurses"
436         fi
437
438         # Check for library containing tgoto.  Do this before curses library
439         # because it may be needed to link the test-case for initscr.
440         AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
441                 for cf_term_lib in $cf_check_list termcap termlib unknown
442                 do
443                         AC_CHECK_LIB($cf_term_lib,tgoto,[break])
444                 done
445         ])
446
447         # Check for library containing initscr
448         test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
449         for cf_curs_lib in $cf_check_list xcurses jcurses unknown
450         do
451                 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
452         done
453         test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
454
455         LIBS="-l$cf_curs_lib $cf_save_LIBS"
456         if test "$cf_term_lib" = unknown ; then
457                 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
458                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
459                         [initscr()],
460                         [cf_result=yes],
461                         [cf_result=no])
462                 AC_MSG_RESULT($cf_result)
463                 test $cf_result = no && AC_ERROR(Cannot link curses library)
464         elif test "$cf_curs_lib" = "$cf_term_lib" ; then
465                 :
466         elif test "$cf_term_lib" != predefined ; then
467                 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
468                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
469                         [initscr(); tgoto((char *)0, 0, 0);],
470                         [cf_result=no],
471                         [
472                         LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
473                         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
474                                 [initscr()],
475                                 [cf_result=yes],
476                                 [cf_result=error])
477                         ])
478                 AC_MSG_RESULT($cf_result)
479         fi
480 fi
481 fi
482
483 ])dnl
484 dnl ---------------------------------------------------------------------------
485 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
486 dnl ----------
487 dnl "dirname" is not portable, so we fake it with a shell script.
488 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
489 dnl ---------------------------------------------------------------------------
490 dnl CF_ENABLE_WARNINGS version: 3 updated: 2003/05/24 14:24:29
491 dnl ------------------
492 dnl Configure-option to enable gcc warnings
493 AC_DEFUN([CF_ENABLE_WARNINGS],[
494 if ( test "$GCC" = yes || test "$GXX" = yes )
495 then
496 AC_MSG_CHECKING(if you want to turn on gcc warnings)
497 CF_ARG_ENABLE(warnings,
498         [  --enable-warnings       test: turn on gcc compiler warnings],
499         [with_warnings=yes],
500         [with_warnings=no])
501 AC_MSG_RESULT($with_warnings)
502 if test "$with_warnings" = "yes"
503 then
504         CF_GCC_WARNINGS
505 fi
506 fi
507 ])dnl
508 dnl ---------------------------------------------------------------------------
509 dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
510 dnl ---------------
511 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
512 dnl prefer a standard location, and use -L options only if we do not find the
513 dnl library in the standard library location(s).
514 dnl     $1 = library name
515 dnl     $2 = library class, usually the same as library name
516 dnl     $3 = includes
517 dnl     $4 = code fragment to compile/link
518 dnl     $5 = corresponding function-name
519 dnl     $6 = flag, nonnull if failure should not cause an error-exit
520 dnl
521 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
522 dnl to use a -L option.
523 AC_DEFUN([CF_FIND_LIBRARY],
524 [
525         eval 'cf_cv_have_lib_'$1'=no'
526         cf_libdir=""
527         AC_CHECK_FUNC($5,
528                 eval 'cf_cv_have_lib_'$1'=yes',[
529                 cf_save_LIBS="$LIBS"
530                 AC_MSG_CHECKING(for $5 in -l$1)
531                 LIBS="-l$1 $LIBS"
532                 AC_TRY_LINK([$3],[$4],
533                         [AC_MSG_RESULT(yes)
534                          eval 'cf_cv_have_lib_'$1'=yes'
535                         ],
536                         [AC_MSG_RESULT(no)
537                         CF_LIBRARY_PATH(cf_search,$2)
538                         for cf_libdir in $cf_search
539                         do
540                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
541                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
542                                 AC_TRY_LINK([$3],[$4],
543                                         [AC_MSG_RESULT(yes)
544                                          eval 'cf_cv_have_lib_'$1'=yes'
545                                          break],
546                                         [AC_MSG_RESULT(no)
547                                          LIBS="$cf_save_LIBS"])
548                         done
549                         ])
550                 ])
551 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
552 ifelse($6,,[
553 if test $cf_found_library = no ; then
554         AC_ERROR(Cannot link $1 library)
555 fi
556 ])
557 ])dnl
558 dnl ---------------------------------------------------------------------------
559 dnl CF_GCC_ATTRIBUTES version: 10 updated: 2005/05/28 13:16:28
560 dnl -----------------
561 dnl Test for availability of useful gcc __attribute__ directives to quiet
562 dnl compiler warnings.  Though useful, not all are supported -- and contrary
563 dnl to documentation, unrecognized directives cause older compilers to barf.
564 AC_DEFUN([CF_GCC_ATTRIBUTES],
565 [
566 if test "$GCC" = yes
567 then
568 cat > conftest.i <<EOF
569 #ifndef GCC_PRINTF
570 #define GCC_PRINTF 0
571 #endif
572 #ifndef GCC_SCANF
573 #define GCC_SCANF 0
574 #endif
575 #ifndef GCC_NORETURN
576 #define GCC_NORETURN /* nothing */
577 #endif
578 #ifndef GCC_UNUSED
579 #define GCC_UNUSED /* nothing */
580 #endif
581 EOF
582 if test "$GCC" = yes
583 then
584         AC_CHECKING([for $CC __attribute__ directives])
585 cat > conftest.$ac_ext <<EOF
586 #line __oline__ "configure"
587 #include "confdefs.h"
588 #include "conftest.h"
589 #include "conftest.i"
590 #if     GCC_PRINTF
591 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
592 #else
593 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
594 #endif
595 #if     GCC_SCANF
596 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
597 #else
598 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
599 #endif
600 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
601 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
602 extern void foo(void) GCC_NORETURN;
603 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
604 EOF
605         for cf_attribute in scanf printf unused noreturn
606         do
607                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
608                 cf_directive="__attribute__(($cf_attribute))"
609                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
610                 case $cf_attribute in
611                 scanf|printf)
612                 cat >conftest.h <<EOF
613 #define GCC_$cf_ATTRIBUTE 1
614 EOF
615                         ;;
616                 *)
617                 cat >conftest.h <<EOF
618 #define GCC_$cf_ATTRIBUTE $cf_directive
619 EOF
620                         ;;
621                 esac
622                 if AC_TRY_EVAL(ac_compile); then
623                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
624                         cat conftest.h >>confdefs.h
625                 fi
626         done
627 else
628         fgrep define conftest.i >>confdefs.h
629 fi
630 rm -rf conftest*
631 fi
632 ])dnl
633 dnl ---------------------------------------------------------------------------
634 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
635 dnl --------------
636 dnl Find version of gcc
637 AC_DEFUN([CF_GCC_VERSION],[
638 AC_REQUIRE([AC_PROG_CC])
639 GCC_VERSION=none
640 if test "$GCC" = yes ; then
641         AC_MSG_CHECKING(version of $CC)
642         GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
643         test -z "$GCC_VERSION" && GCC_VERSION=unknown
644         AC_MSG_RESULT($GCC_VERSION)
645 fi
646 ])dnl
647 dnl ---------------------------------------------------------------------------
648 dnl CF_GCC_WARNINGS version: 20 updated: 2005/08/06 18:37:29
649 dnl ---------------
650 dnl Check if the compiler supports useful warning options.  There's a few that
651 dnl we don't use, simply because they're too noisy:
652 dnl
653 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
654 dnl     -Wredundant-decls (system headers make this too noisy)
655 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
656 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
657 dnl             is enabled for ncurses using "--enable-const".
658 dnl     -pedantic
659 dnl
660 dnl Parameter:
661 dnl     $1 is an optional list of gcc warning flags that a particular
662 dnl             application might want to use, e.g., "no-unused" for
663 dnl             -Wno-unused
664 dnl Special:
665 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
666 dnl
667 AC_DEFUN([CF_GCC_WARNINGS],
668 [
669 AC_REQUIRE([CF_GCC_VERSION])
670 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
671
672 cat > conftest.$ac_ext <<EOF
673 #line __oline__ "configure"
674 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
675 EOF
676
677 if test "$INTEL_COMPILER" = yes
678 then
679 # The "-wdXXX" options suppress warnings:
680 # remark #1419: external declaration in primary source file
681 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
682 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
683 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
684 # remark #193: zero used for undefined preprocessing identifier
685 # remark #593: variable "curs_sb_left_arrow" was set but never used
686 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
687 # remark #869: parameter "tw" was never referenced
688 # remark #981: operands are evaluated in unspecified order
689 # warning #269: invalid format string conversion
690
691         AC_CHECKING([for $CC warning options])
692         cf_save_CFLAGS="$CFLAGS"
693         EXTRA_CFLAGS="-Wall"
694         for cf_opt in $1 \
695                 wd1419 \
696                 wd1682 \
697                 wd1683 \
698                 wd1684 \
699                 wd193 \
700                 wd279 \
701                 wd593 \
702                 wd810 \
703                 wd869 \
704                 wd981
705         do
706                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
707                 if AC_TRY_EVAL(ac_compile); then
708                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
709                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
710                 fi
711         done
712         CFLAGS="$cf_save_CFLAGS"
713
714 elif test "$GCC" = yes
715 then
716         AC_CHECKING([for $CC warning options])
717         cf_save_CFLAGS="$CFLAGS"
718         EXTRA_CFLAGS="-W -Wall"
719         cf_warn_CONST=""
720         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
721         for cf_opt in \
722                 Wbad-function-cast \
723                 Wcast-align \
724                 Wcast-qual \
725                 Winline \
726                 Wmissing-declarations \
727                 Wmissing-prototypes \
728                 Wnested-externs \
729                 Wpointer-arith \
730                 Wshadow \
731                 Wstrict-prototypes \
732                 Wundef $cf_warn_CONST $1
733         do
734                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
735                 if AC_TRY_EVAL(ac_compile); then
736                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
737                         case $cf_opt in #(vi
738                         Wcast-qual) #(vi
739                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
740                                 ;;
741                         Winline) #(vi
742                                 case $GCC_VERSION in
743                                 3.3*)
744                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
745                                         continue;;
746                                 esac
747                                 ;;
748                         esac
749                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
750                 fi
751         done
752         CFLAGS="$cf_save_CFLAGS"
753 fi
754 rm -f conftest*
755
756 AC_SUBST(EXTRA_CFLAGS)
757 ])dnl
758 dnl ---------------------------------------------------------------------------
759 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
760 dnl -------------
761 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
762 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
763 dnl (or misfeature) of glibc2, which breaks portability of many applications,
764 dnl since it is interwoven with GNU extensions.
765 dnl
766 dnl Well, yes we could work around it...
767 AC_DEFUN([CF_GNU_SOURCE],
768 [
769 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
770 AC_TRY_COMPILE([#include <sys/types.h>],[
771 #ifndef _XOPEN_SOURCE
772 make an error
773 #endif],
774         [cf_cv_gnu_source=no],
775         [cf_save="$CPPFLAGS"
776          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
777          AC_TRY_COMPILE([#include <sys/types.h>],[
778 #ifdef _XOPEN_SOURCE
779 make an error
780 #endif],
781         [cf_cv_gnu_source=no],
782         [cf_cv_gnu_source=yes])
783         CPPFLAGS="$cf_save"
784         ])
785 ])
786 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
787 ])dnl
788 dnl ---------------------------------------------------------------------------
789 dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
790 dnl --------------
791 dnl Construct a search-list for a nonstandard header-file
792 AC_DEFUN([CF_HEADER_PATH],
793 [CF_SUBDIR_PATH($1,$2,include)
794 test "$includedir" != NONE && \
795 test "$includedir" != "/usr/include" && \
796 test -d "$includedir" && {
797         test -d $includedir &&    $1="[$]$1 $includedir"
798         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
799 }
800
801 test "$oldincludedir" != NONE && \
802 test "$oldincludedir" != "/usr/include" && \
803 test -d "$oldincludedir" && {
804         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
805         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
806 }
807
808 ])dnl
809 dnl ---------------------------------------------------------------------------
810 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
811 dnl -----------------
812 dnl If we do not have a given script, look for it in the parent directory.
813 AC_DEFUN([CF_INHERIT_SCRIPT],
814 [
815 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
816 ])dnl
817 dnl ---------------------------------------------------------------------------
818 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
819 dnl -----------------
820 dnl Check if the given compiler is really the Intel compiler for Linux.  It
821 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
822 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
823 dnl
824 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
825 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
826 dnl the wrappers for gcc and g++ warnings.
827 dnl
828 dnl $1 = GCC (default) or GXX
829 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
830 dnl $3 = CFLAGS (default) or CXXFLAGS
831 AC_DEFUN([CF_INTEL_COMPILER],[
832 ifelse($2,,INTEL_COMPILER,[$2])=no
833
834 if test "$ifelse($1,,[$1],GCC)" = yes ; then
835         case $host_os in
836         linux*|gnu*)
837                 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
838                 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
839                 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
840                 AC_TRY_COMPILE([],[
841 #ifdef __INTEL_COMPILER
842 #else
843 make an error
844 #endif
845 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
846 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
847 ],[])
848                 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
849                 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
850                 ;;
851         esac
852 fi
853 ])dnl
854 dnl ---------------------------------------------------------------------------
855 dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
856 dnl ---------------
857 dnl Construct a search-list for a nonstandard library-file
858 AC_DEFUN([CF_LIBRARY_PATH],
859 [CF_SUBDIR_PATH($1,$2,lib)])dnl
860 dnl ---------------------------------------------------------------------------
861 dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
862 dnl ------------
863 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
864 dnl a monocase filesystem.
865 AC_DEFUN([CF_MAKE_TAGS],[
866 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
867 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
868
869 if test "$cf_cv_mixedcase" = yes ; then
870         AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
871 else
872         MAKE_UPPER_TAGS=no
873 fi
874
875 if test "$MAKE_UPPER_TAGS" = yes ; then
876         MAKE_UPPER_TAGS=
877 else
878         MAKE_UPPER_TAGS="#"
879 fi
880 AC_SUBST(MAKE_UPPER_TAGS)
881
882 if test "$MAKE_LOWER_TAGS" = yes ; then
883         MAKE_LOWER_TAGS=
884 else
885         MAKE_LOWER_TAGS="#"
886 fi
887 AC_SUBST(MAKE_LOWER_TAGS)
888 ])dnl
889 dnl ---------------------------------------------------------------------------
890 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
891 dnl ----------------------
892 dnl Check if the file-system supports mixed-case filenames.  If we're able to
893 dnl create a lowercase name and see it as uppercase, it doesn't support that.
894 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
895 [
896 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
897 if test "$cross_compiling" = yes ; then
898         case $target_alias in #(vi
899         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
900                 cf_cv_mixedcase=no
901                 ;;
902         *)
903                 cf_cv_mixedcase=yes
904                 ;;
905         esac
906 else
907         rm -f conftest CONFTEST
908         echo test >conftest
909         if test -f CONFTEST ; then
910                 cf_cv_mixedcase=no
911         else
912                 cf_cv_mixedcase=yes
913         fi
914         rm -f conftest CONFTEST
915 fi
916 ])
917 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
918 ])dnl
919 dnl ---------------------------------------------------------------------------
920 dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
921 dnl ----------
922 dnl Write a debug message to config.log, along with the line number in the
923 dnl configure script.
924 AC_DEFUN([CF_MSG_LOG],[
925 echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
926 ])dnl
927 dnl ---------------------------------------------------------------------------
928 dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
929 dnl -------------------
930 dnl Check if we can compile with ncurses' header file
931 dnl $1 is the cache variable to set
932 dnl $2 is the header-file to include
933 dnl $3 is the root name (ncurses or ncursesw)
934 AC_DEFUN([CF_NCURSES_CC_CHECK],[
935         AC_TRY_COMPILE([
936 ]ifelse($3,ncursesw,[
937 #define _XOPEN_SOURCE_EXTENDED
938 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
939 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
940 ])[
941 #include <$2>],[
942 #ifdef NCURSES_VERSION
943 ]ifelse($3,ncursesw,[
944 #ifndef WACS_BSSB
945         make an error
946 #endif
947 ])[
948 printf("%s\n", NCURSES_VERSION);
949 #else
950 #ifdef __NCURSES_H
951 printf("old\n");
952 #else
953         make an error
954 #endif
955 #endif
956         ]
957         ,[$1=$cf_header]
958         ,[$1=no])
959 ])dnl
960 dnl ---------------------------------------------------------------------------
961 dnl CF_NCURSES_CONFIG version: 4 updated: 2006/10/28 14:36:12
962 dnl -----------------
963 dnl Tie together the configure-script macros for ncurses.
964 dnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
965 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
966 dnl
967 dnl $1 is the root library name (default: "ncurses")
968 AC_DEFUN([CF_NCURSES_CONFIG],
969 [
970 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
971
972 echo "Looking for ${cf_ncuconfig_root}-config"
973 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
974
975 if test "$NCURSES_CONFIG" != none ; then
976
977 cf_cv_ncurses_header=curses.h
978
979 CPPFLAGS="`$NCURSES_CONFIG --cflags` $CPPFLAGS"
980 LIBS="`$NCURSES_CONFIG --libs` $LIBS"
981
982 dnl like CF_NCURSES_CPPFLAGS
983 AC_DEFINE(NCURSES)
984
985 dnl like CF_NCURSES_LIBS
986 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
987 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
988
989 dnl like CF_NCURSES_VERSION
990 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
991
992 else
993
994 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
995 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
996
997 fi
998 ])dnl
999 dnl ---------------------------------------------------------------------------
1000 dnl CF_NCURSES_CPPFLAGS version: 18 updated: 2005/12/31 13:26:39
1001 dnl -------------------
1002 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1003 dnl the CPPFLAGS variable so we can include its header.
1004 dnl
1005 dnl The header files may be installed as either curses.h, or ncurses.h (would
1006 dnl be obsolete, except that some packagers prefer this name to distinguish it
1007 dnl from a "native" curses implementation).  If not installed for overwrite,
1008 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1009 dnl /usr/include/ncurses), but someone may have installed overwriting the
1010 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
1011 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1012 dnl the header.
1013 dnl
1014 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1015 dnl is already in the include-path, don't even bother with this, since we cannot
1016 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
1017 dnl
1018 dnl The optional parameter gives the root name of the library, in case it is
1019 dnl not installed as the default curses library.  That is how the
1020 dnl wide-character version of ncurses is installed.
1021 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1022 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1023
1024 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1025 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1026
1027 test -n "$cf_cv_curses_dir" && \
1028 test "$cf_cv_curses_dir" != "no" && \
1029 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
1030
1031 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1032         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1033         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1034         for cf_header in $cf_header_list
1035         do
1036                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1037                 test "$cf_cv_ncurses_h" != no && break
1038         done
1039 ])
1040
1041 CF_NCURSES_HEADER
1042 CF_TERM_HEADER
1043
1044 # some applications need this, but should check for NCURSES_VERSION
1045 AC_DEFINE(NCURSES)
1046
1047 CF_NCURSES_VERSION
1048 ])dnl
1049 dnl ---------------------------------------------------------------------------
1050 dnl CF_NCURSES_HEADER version: 1 updated: 2005/12/31 13:28:37
1051 dnl -----------------
1052 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1053 dnl variations of ncurses' installs.
1054 dnl
1055 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1056 AC_DEFUN([CF_NCURSES_HEADER],[
1057
1058 if test "$cf_cv_ncurses_h" != no ; then
1059         cf_cv_ncurses_header=$cf_cv_ncurses_h
1060 else
1061
1062 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1063         test -n "$verbose" && echo
1064         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1065         test -n "$verbose" && echo search path $cf_search
1066         cf_save2_CPPFLAGS="$CPPFLAGS"
1067         for cf_incdir in $cf_search
1068         do
1069                 CF_ADD_INCDIR($cf_incdir)
1070                 for cf_header in \
1071                         ncurses.h \
1072                         curses.h
1073                 do
1074                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1075                         if test "$cf_cv_ncurses_h2" != no ; then
1076                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1077                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
1078                                 break
1079                         fi
1080                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1081                 done
1082                 CPPFLAGS="$cf_save2_CPPFLAGS"
1083                 test "$cf_cv_ncurses_h2" != no && break
1084         done
1085         test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found)
1086         ])
1087
1088         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1089         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1090         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1091                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1092         fi
1093         CF_ADD_INCDIR($cf_1st_incdir)
1094
1095 fi
1096
1097 # Set definitions to allow ifdef'ing for ncurses.h
1098
1099 case $cf_cv_ncurses_header in # (vi
1100 *ncurses.h)
1101         AC_DEFINE(HAVE_NCURSES_H)
1102         ;;
1103 esac
1104
1105 case $cf_cv_ncurses_header in # (vi
1106 ncurses/curses.h|ncurses/ncurses.h)
1107         AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1108         ;;
1109 ncursesw/curses.h|ncursesw/ncurses.h)
1110         AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1111         ;;
1112 esac
1113
1114 ])dnl
1115 dnl ---------------------------------------------------------------------------
1116 dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05
1117 dnl ---------------
1118 dnl Look for the ncurses library.  This is a little complicated on Linux,
1119 dnl because it may be linked with the gpm (general purpose mouse) library.
1120 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1121 dnl unusable with ncurses.  However, we don't want to link with gpm unless
1122 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1123 dnl and the linker will record a dependency.
1124 dnl
1125 dnl The optional parameter gives the root name of the library, in case it is
1126 dnl not installed as the default curses library.  That is how the
1127 dnl wide-character version of ncurses is installed.
1128 AC_DEFUN([CF_NCURSES_LIBS],
1129 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1130
1131 cf_nculib_root=ifelse($1,,ncurses,$1)
1132         # This works, except for the special case where we find gpm, but
1133         # ncurses is in a nonstandard location via $LIBS, and we really want
1134         # to link gpm.
1135 cf_ncurses_LIBS=""
1136 cf_ncurses_SAVE="$LIBS"
1137 AC_CHECK_LIB(gpm,Gpm_Open,
1138         [AC_CHECK_LIB(gpm,initscr,
1139                 [LIBS="$cf_ncurses_SAVE"],
1140                 [cf_ncurses_LIBS="-lgpm"])])
1141
1142 case $host_os in #(vi
1143 freebsd*)
1144         # This is only necessary if you are linking against an obsolete
1145         # version of ncurses (but it should do no harm, since it's static).
1146         if test "$cf_nculib_root" = ncurses ; then
1147                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1148         fi
1149         ;;
1150 esac
1151
1152 LIBS="$cf_ncurses_LIBS $LIBS"
1153
1154 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1155 then
1156         LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
1157 else
1158         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1159                 [#include <${cf_cv_ncurses_header-curses.h}>],
1160                 [initscr()],
1161                 initscr)
1162 fi
1163
1164 if test -n "$cf_ncurses_LIBS" ; then
1165         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1166         cf_ncurses_SAVE="$LIBS"
1167         for p in $cf_ncurses_LIBS ; do
1168                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1169                 if test "$q" != "$LIBS" ; then
1170                         LIBS="$q"
1171                 fi
1172         done
1173         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1174                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1175                 [AC_MSG_RESULT(yes)],
1176                 [AC_MSG_RESULT(no)
1177                  LIBS="$cf_ncurses_SAVE"])
1178 fi
1179
1180 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1181 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1182 ])dnl
1183 dnl ---------------------------------------------------------------------------
1184 dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57
1185 dnl ------------------
1186 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1187 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
1188 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1189 AC_DEFUN([CF_NCURSES_VERSION],
1190 [
1191 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1192 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1193         cf_cv_ncurses_version=no
1194         cf_tempfile=out$$
1195         rm -f $cf_tempfile
1196         AC_TRY_RUN([
1197 #include <${cf_cv_ncurses_header-curses.h}>
1198 #include <stdio.h>
1199 int main()
1200 {
1201         FILE *fp = fopen("$cf_tempfile", "w");
1202 #ifdef NCURSES_VERSION
1203 # ifdef NCURSES_VERSION_PATCH
1204         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1205 # else
1206         fprintf(fp, "%s\n", NCURSES_VERSION);
1207 # endif
1208 #else
1209 # ifdef __NCURSES_H
1210         fprintf(fp, "old\n");
1211 # else
1212         make an error
1213 # endif
1214 #endif
1215         exit(0);
1216 }],[
1217         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1218
1219         # This will not work if the preprocessor splits the line after the
1220         # Autoconf token.  The 'unproto' program does that.
1221         cat > conftest.$ac_ext <<EOF
1222 #include <${cf_cv_ncurses_header-curses.h}>
1223 #undef Autoconf
1224 #ifdef NCURSES_VERSION
1225 Autoconf NCURSES_VERSION
1226 #else
1227 #ifdef __NCURSES_H
1228 Autoconf "old"
1229 #endif
1230 ;
1231 #endif
1232 EOF
1233         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1234         AC_TRY_EVAL(cf_try)
1235         if test -f conftest.out ; then
1236                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1237                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1238                 rm -f conftest.out
1239         fi
1240 ])
1241         rm -f $cf_tempfile
1242 ])
1243 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1244 ])dnl
1245 dnl ---------------------------------------------------------------------------
1246 dnl CF_PATH_SYNTAX version: 11 updated: 2006/09/02 08:55:46
1247 dnl --------------
1248 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1249 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1250 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1251 dnl delayed evaluation of those symbols.
1252 AC_DEFUN([CF_PATH_SYNTAX],[
1253 if test "x$prefix" != xNONE; then
1254   cf_path_syntax="$prefix"
1255 else
1256   cf_path_syntax="$ac_default_prefix"
1257 fi
1258
1259 case ".[$]$1" in #(vi
1260 .\[$]\(*\)*|.\'*\'*) #(vi
1261   ;;
1262 ..|./*|.\\*) #(vi
1263   ;;
1264 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1265   ;;
1266 .\[$]{*prefix}*) #(vi
1267   eval $1="[$]$1"
1268   case ".[$]$1" in #(vi
1269   .NONE/*)
1270     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1271     ;;
1272   esac
1273   ;; #(vi
1274 .no|.NONE/*)
1275   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1276   ;;
1277 *)
1278   ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1279   ;;
1280 esac
1281 ])dnl
1282 dnl ---------------------------------------------------------------------------
1283 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1284 dnl -----------------
1285 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1286 dnl
1287 dnl     POSIX.1-1990                            _POSIX_SOURCE
1288 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
1289 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
1290 dnl             Bindings Option
1291 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
1292 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
1293 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
1294 dnl
1295 dnl Parameters:
1296 dnl     $1 is the nominal value for _POSIX_C_SOURCE
1297 AC_DEFUN([CF_POSIX_C_SOURCE],
1298 [
1299 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1300
1301 cf_save_CFLAGS="$CFLAGS"
1302 cf_save_CPPFLAGS="$CPPFLAGS"
1303
1304 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1305 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1306
1307 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1308         CF_MSG_LOG(if the symbol is already defined go no further)
1309         AC_TRY_COMPILE([#include <sys/types.h>],[
1310 #ifndef _POSIX_C_SOURCE
1311 make an error
1312 #endif],
1313         [cf_cv_posix_c_source=no],
1314         [cf_want_posix_source=no
1315          case .$cf_POSIX_C_SOURCE in #(vi
1316          .[[12]]??*) #(vi
1317                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1318                 ;;
1319          .2) #(vi
1320                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1321                 cf_want_posix_source=yes
1322                 ;;
1323          .*)
1324                 cf_want_posix_source=yes
1325                 ;;
1326          esac
1327          if test "$cf_want_posix_source" = yes ; then
1328                 AC_TRY_COMPILE([#include <sys/types.h>],[
1329 #ifdef _POSIX_SOURCE
1330 make an error
1331 #endif],[],
1332                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1333          fi
1334          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1335          CFLAGS="$cf_trim_CFLAGS"
1336          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1337          CF_MSG_LOG(if the second compile does not leave our definition intact error)
1338          AC_TRY_COMPILE([#include <sys/types.h>],[
1339 #ifndef _POSIX_C_SOURCE
1340 make an error
1341 #endif],,
1342          [cf_cv_posix_c_source=no])
1343          CFLAGS="$cf_save_CFLAGS"
1344          CPPFLAGS="$cf_save_CPPFLAGS"
1345         ])
1346 ])
1347
1348 if test "$cf_cv_posix_c_source" != no ; then
1349         CFLAGS="$cf_trim_CFLAGS"
1350         CPPFLAGS="$cf_trim_CPPFLAGS"
1351         if test "$cf_cv_cc_u_d_options" = yes ; then
1352                 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1353                                 sed -e 's/-D/-U/g' -e 's/=[[^   ]]*//g'`
1354                 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1355         fi
1356         CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1357 fi
1358
1359 ])dnl
1360 dnl ---------------------------------------------------------------------------
1361 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
1362 dnl ------------
1363 dnl Append definitions and rules for the given programs to the subdirectory
1364 dnl Makefiles, and the recursion rule for the top-level Makefile.
1365 dnl
1366 dnl parameters
1367 dnl     $1 = script to run
1368 dnl     $2 = list of subdirectories
1369 dnl
1370 dnl variables
1371 dnl     $AWK
1372 AC_DEFUN([CF_PRG_RULES],
1373 [
1374 for cf_dir in $2
1375 do
1376         if test ! -d $srcdir/$cf_dir; then
1377                 continue
1378         elif test -f $srcdir/$cf_dir/programs; then
1379                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
1380         fi
1381 done
1382
1383 ])dnl
1384 dnl ---------------------------------------------------------------------------
1385 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1386 dnl --------------
1387 dnl Check if C (preprocessor) -U and -D options are processed in the order
1388 dnl given rather than by type of option.  Some compilers insist on apply all
1389 dnl of the -U options after all of the -D options.  Others allow mixing them,
1390 dnl and may predefine symbols that conflict with those we define.
1391 AC_DEFUN([CF_PROG_CC_U_D],
1392 [
1393 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1394         cf_save_CPPFLAGS="$CPPFLAGS"
1395         CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1396         AC_TRY_COMPILE([],[
1397 #ifndef U_D_OPTIONS
1398 make an undefined-error
1399 #endif
1400 #ifdef  D_U_OPTIONS
1401 make a defined-error
1402 #endif
1403         ],[
1404         cf_cv_cc_u_d_options=yes],[
1405         cf_cv_cc_u_d_options=no])
1406         CPPFLAGS="$cf_save_CPPFLAGS"
1407 ])
1408 ])dnl
1409 dnl ---------------------------------------------------------------------------
1410 dnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
1411 dnl ---------------
1412 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
1413 dnl misc/tabset install won't work properly.  Usually this happens only when
1414 dnl using the fallback mkinstalldirs script
1415 AC_DEFUN([CF_PROG_INSTALL],
1416 [AC_PROG_INSTALL
1417 case $INSTALL in
1418 /*)
1419   ;;
1420 *)
1421   CF_DIRNAME(cf_dir,$INSTALL)
1422   test -z "$cf_dir" && cf_dir=.
1423   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
1424   ;;
1425 esac
1426 ])dnl
1427 dnl ---------------------------------------------------------------------------
1428 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1429 dnl ----------------
1430 dnl Remove all -U and -D options that refer to the given symbol from a list
1431 dnl of C compiler options.  This works around the problem that not all
1432 dnl compilers process -U and -D options from left-to-right, so a -U option
1433 dnl cannot be used to cancel the effect of a preceding -D option.
1434 dnl
1435 dnl $1 = target (which could be the same as the source variable)
1436 dnl $2 = source (including '$')
1437 dnl $3 = symbol to remove
1438 define([CF_REMOVE_DEFINE],
1439 [
1440 # remove $3 symbol from $2
1441 $1=`echo "$2" | \
1442         sed     -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[[       ]]/ /g' \
1443                 -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[$]//g'`
1444 ])dnl
1445 dnl ---------------------------------------------------------------------------
1446 dnl CF_SUBDIR_PATH version: 4 updated: 2006/11/18 17:13:19
1447 dnl --------------
1448 dnl Construct a search-list for a nonstandard header/lib-file
1449 dnl     $1 = the variable to return as result
1450 dnl     $2 = the package name
1451 dnl     $3 = the subdirectory, e.g., bin, include or lib
1452 AC_DEFUN([CF_SUBDIR_PATH],
1453 [$1=""
1454
1455 test -d "[$]HOME" && {
1456         test -n "$verbose" && echo "    ... testing $3-directories under [$]HOME"
1457         test -d "[$]HOME/$3" &&          $1="[$]$1 [$]HOME/$3"
1458         test -d "[$]HOME/$3/$2" &&       $1="[$]$1 [$]HOME/$3/$2"
1459         test -d "[$]HOME/$3/$2/$3" &&    $1="[$]$1 [$]HOME/$3/$2/$3"
1460 }
1461
1462 # For other stuff under the home directory, it should be sufficient to put
1463 # a symbolic link for $HOME/$2 to the actual package location:
1464 test -d "[$]HOME/$2" && {
1465         test -n "$verbose" && echo "    ... testing $3-directories under [$]HOME/$2"
1466         test -d "[$]HOME/$2/$3" &&       $1="[$]$1 [$]HOME/$2/$3"
1467         test -d "[$]HOME/$2/$3/$2" &&    $1="[$]$1 [$]HOME/$2/$3/$2"
1468 }
1469
1470 test "$prefix" != /usr/local && \
1471 test -d /usr/local && {
1472         test -n "$verbose" && echo "    ... testing $3-directories under /usr/local"
1473         test -d /usr/local/$3 &&       $1="[$]$1 /usr/local/$3"
1474         test -d /usr/local/$3/$2 &&    $1="[$]$1 /usr/local/$3/$2"
1475         test -d /usr/local/$3/$2/$3 && $1="[$]$1 /usr/local/$3/$2/$3"
1476         test -d /usr/local/$2/$3 &&    $1="[$]$1 /usr/local/$2/$3"
1477         test -d /usr/local/$2/$3/$2 && $1="[$]$1 /usr/local/$2/$3/$2"
1478 }
1479
1480 test "$prefix" != NONE && \
1481 test -d $prefix && {
1482         test -n "$verbose" && echo "    ... testing $3-directories under $prefix"
1483         test -d $prefix/$3 &&          $1="[$]$1 $prefix/$3"
1484         test -d $prefix/$3/$2 &&       $1="[$]$1 $prefix/$3/$2"
1485         test -d $prefix/$3/$2/$3 &&    $1="[$]$1 $prefix/$3/$2/$3"
1486         test -d $prefix/$2/$3 &&       $1="[$]$1 $prefix/$2/$3"
1487         test -d $prefix/$2/$3/$2 &&    $1="[$]$1 $prefix/$2/$3/$2"
1488 }
1489
1490 test "$prefix" != /opt && \
1491 test -d /opt && {
1492         test -n "$verbose" && echo "    ... testing $3-directories under /opt"
1493         test -d /opt/$3 &&             $1="[$]$1 /opt/$3"
1494         test -d /opt/$3/$2 &&          $1="[$]$1 /opt/$3/$2"
1495         test -d /opt/$3/$2/$3 &&       $1="[$]$1 /opt/$3/$2/$3"
1496         test -d /opt/$2/$3 &&          $1="[$]$1 /opt/$2/$3"
1497         test -d /opt/$2/$3/$2 &&       $1="[$]$1 /opt/$2/$3/$2"
1498 }
1499
1500 test "$prefix" != /usr && \
1501 test -d /usr && {
1502         test -n "$verbose" && echo "    ... testing $3-directories under /usr"
1503         test -d /usr/$3 &&             $1="[$]$1 /usr/$3"
1504         test -d /usr/$3/$2 &&          $1="[$]$1 /usr/$3/$2"
1505         test -d /usr/$3/$2/$3 &&       $1="[$]$1 /usr/$3/$2/$3"
1506         test -d /usr/$2/$3 &&          $1="[$]$1 /usr/$2/$3"
1507 }
1508 ])dnl
1509 dnl ---------------------------------------------------------------------------
1510 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1511 dnl ------------------
1512 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1513 dnl older SCO configurations.
1514 AC_DEFUN([CF_SYS_TIME_SELECT],
1515 [
1516 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1517 AC_CACHE_VAL(cf_cv_sys_time_select,[
1518 AC_TRY_COMPILE([
1519 #include <sys/types.h>
1520 #ifdef HAVE_SYS_TIME_H
1521 #include <sys/time.h>
1522 #endif
1523 #ifdef HAVE_SYS_SELECT_H
1524 #include <sys/select.h>
1525 #endif
1526 ],[],[cf_cv_sys_time_select=yes],
1527      [cf_cv_sys_time_select=no])
1528      ])
1529 AC_MSG_RESULT($cf_cv_sys_time_select)
1530 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1531 ])dnl
1532 dnl ---------------------------------------------------------------------------
1533 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
1534 dnl --------------
1535 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
1536 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
1537 dnl but some packagers change this, breaking various applications.
1538 AC_DEFUN([CF_TERM_HEADER],[
1539 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
1540 case ${cf_cv_ncurses_header} in #(vi
1541 */ncurses.h|*/ncursesw.h) #(vi
1542         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
1543         ;;
1544 *)
1545         cf_term_header=term.h
1546         ;;
1547 esac
1548
1549 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
1550 do
1551 AC_TRY_COMPILE([#include <stdio.h>
1552 #include <${cf_cv_ncurses_header-curses.h}>
1553 #include <$cf_test>
1554 ],[int x = auto_left_margin],[
1555         cf_cv_term_header="$cf_test"],[
1556         cf_cv_term_header=unknown
1557         ])
1558         test "$cf_cv_term_header" != unknown && break
1559 done
1560 ])
1561
1562 # Set definitions to allow ifdef'ing to accommodate subdirectories
1563
1564 case $cf_cv_term_header in # (vi
1565 *term.h)
1566         AC_DEFINE(HAVE_TERM_H)
1567         ;;
1568 esac
1569
1570 case $cf_cv_term_header in # (vi
1571 ncurses/term.h) #(vi
1572         AC_DEFINE(HAVE_NCURSES_TERM_H)
1573         ;;
1574 ncursesw/term.h)
1575         AC_DEFINE(HAVE_NCURSESW_TERM_H)
1576         ;;
1577 esac
1578 ])dnl
1579 dnl ---------------------------------------------------------------------------
1580 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1581 dnl --------
1582 dnl Make an uppercase version of a variable
1583 dnl $1=uppercase($2)
1584 AC_DEFUN([CF_UPPER],
1585 [
1586 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1587 ])dnl
1588 dnl ---------------------------------------------------------------------------
1589 dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
1590 dnl ----------
1591 dnl Use AC_VERBOSE w/o the warnings
1592 AC_DEFUN([CF_VERBOSE],
1593 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
1594 ])dnl
1595 dnl ---------------------------------------------------------------------------
1596 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
1597 dnl ------------------
1598 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
1599 dnl libraries.
1600 AC_DEFUN([CF_WITH_CURSES_DIR],[
1601 AC_ARG_WITH(curses-dir,
1602         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
1603         [CF_PATH_SYNTAX(withval)
1604          cf_cv_curses_dir=$withval],
1605         [cf_cv_curses_dir=no])
1606 ])dnl
1607 dnl ---------------------------------------------------------------------------
1608 dnl CF_XOPEN_SOURCE version: 24 updated: 2006/04/02 16:41:09
1609 dnl ---------------
1610 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1611 dnl or adapt to the vendor's definitions to get equivalent functionality,
1612 dnl without losing the common non-POSIX features.
1613 dnl
1614 dnl Parameters:
1615 dnl     $1 is the nominal value for _XOPEN_SOURCE
1616 dnl     $2 is the nominal value for _POSIX_C_SOURCE
1617 AC_DEFUN([CF_XOPEN_SOURCE],[
1618
1619 AC_REQUIRE([CF_PROG_CC_U_D])
1620
1621 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
1622 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
1623
1624 case $host_os in #(vi
1625 aix[[45]]*) #(vi
1626         CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
1627         ;;
1628 freebsd*) #(vi
1629         # 5.x headers associate
1630         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1631         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1632         cf_POSIX_C_SOURCE=200112L
1633         cf_XOPEN_SOURCE=600
1634         CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1635         ;;
1636 hpux*) #(vi
1637         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
1638         ;;
1639 irix[[56]].*) #(vi
1640         CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
1641         ;;
1642 linux*|gnu*) #(vi
1643         CF_GNU_SOURCE
1644         ;;
1645 mirbsd*) #(vi
1646         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
1647         ;;
1648 netbsd*) #(vi
1649         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1650         ;;
1651 openbsd*) #(vi
1652         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1653         ;;
1654 osf[[45]]*) #(vi
1655         CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
1656         ;;
1657 nto-qnx*) #(vi
1658         CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
1659         ;;
1660 sco*) #(vi
1661         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1662         ;;
1663 solaris*) #(vi
1664         CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1665         ;;
1666 *)
1667         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1668         AC_TRY_COMPILE([#include <sys/types.h>],[
1669 #ifndef _XOPEN_SOURCE
1670 make an error
1671 #endif],
1672         [cf_cv_xopen_source=no],
1673         [cf_save="$CPPFLAGS"
1674          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1675          AC_TRY_COMPILE([#include <sys/types.h>],[
1676 #ifdef _XOPEN_SOURCE
1677 make an error
1678 #endif],
1679         [cf_cv_xopen_source=no],
1680         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1681         CPPFLAGS="$cf_save"
1682         ])
1683 ])
1684         if test "$cf_cv_xopen_source" != no ; then
1685                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1686                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1687                 test "$cf_cv_cc_u_d_options" = yes && \
1688                         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
1689                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
1690         fi
1691         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1692         ;;
1693 esac
1694 ])