blob: afc50fea05ce80973556e92e7721ef5964e6406d [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301dnl***************************************************************************
2dnl Copyright (c) 2003-2007,2008 Free Software Foundation, Inc. *
3dnl *
4dnl Permission is hereby granted, free of charge, to any person obtaining a *
5dnl copy of this software and associated documentation files (the *
6dnl "Software"), to deal in the Software without restriction, including *
7dnl without limitation the rights to use, copy, modify, merge, publish, *
8dnl distribute, distribute with modifications, sublicense, and/or sell *
9dnl copies of the Software, and to permit persons to whom the Software is *
10dnl furnished to do so, subject to the following conditions: *
11dnl *
12dnl The above copyright notice and this permission notice shall be included *
13dnl in all copies or substantial portions of the Software. *
14dnl *
15dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22dnl *
23dnl Except as contained in this notice, the name(s) of the above copyright *
24dnl holders shall not be used in advertising or otherwise to promote the *
25dnl sale, use or other dealings in this Software without prior written *
26dnl authorization. *
27dnl***************************************************************************
28dnl
29dnl $Id: aclocal.m4,v 1.22 2008/02/09 18:22:17 tom Exp $
30dnl
31dnl Author: Thomas E. Dickey
32dnl
33dnl Macros used in NCURSES test programs auto-configuration script.
34dnl
35dnl These macros are maintained separately from NCURSES. The copyright on
36dnl this file applies to the aggregation of macros and does not affect use of
37dnl these macros in other applications.
38dnl
39dnl See http://invisible-island.net/autoconf/ for additional information.
40dnl
41dnl ---------------------------------------------------------------------------
42dnl ---------------------------------------------------------------------------
43dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
44dnl -------------
45dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
46dnl The second parameter if given makes this macro verbose.
47dnl
48dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
49dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
50dnl confused by the quotes (which require backslashes to keep them usable).
51AC_DEFUN([CF_ADD_CFLAGS],
52[
53cf_fix_cppflags=no
54cf_new_cflags=
55cf_new_cppflags=
56cf_new_extra_cppflags=
57
58for cf_add_cflags in $1
59do
60case $cf_fix_cppflags in
61no)
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 ;;
94yes)
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 ;;
103esac
104done
105
106if test -n "$cf_new_cflags" ; then
107 ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
108 CFLAGS="$CFLAGS $cf_new_cflags"
109fi
110
111if test -n "$cf_new_cppflags" ; then
112 ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
113 CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
114fi
115
116if 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"
119fi
120
121AC_SUBST(EXTRA_CPPFLAGS)
122
123])dnl
124dnl ---------------------------------------------------------------------------
125dnl CF_ADD_INCDIR version: 9 updated: 2008/02/09 13:15:34
126dnl -------------
127dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's
128dnl redundant. We don't normally need to add -I/usr/local/include for gcc,
129dnl but old versions (and some misinstalled ones) need that. To make things
130dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
131dnl the include-path).
132AC_DEFUN([CF_ADD_INCDIR],
133[
134if test -n "$1" ; then
135 for cf_add_incdir in $1
136 do
137 while test $cf_add_incdir != /usr/include
138 do
139 if test -d $cf_add_incdir
140 then
141 cf_have_incdir=no
142 if test -n "$CFLAGS$CPPFLAGS" ; then
143 # a loop is needed to ensure we can add subdirs of existing dirs
144 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
145 if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
146 cf_have_incdir=yes; break
147 fi
148 done
149 fi
150
151 if test "$cf_have_incdir" = no ; then
152 if test "$cf_add_incdir" = /usr/local/include ; then
153 if test "$GCC" = yes
154 then
155 cf_save_CPPFLAGS=$CPPFLAGS
156 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
157 AC_TRY_COMPILE([#include <stdio.h>],
158 [printf("Hello")],
159 [],
160 [cf_have_incdir=yes])
161 CPPFLAGS=$cf_save_CPPFLAGS
162 fi
163 fi
164 fi
165
166 if test "$cf_have_incdir" = no ; then
167 CF_VERBOSE(adding $cf_add_incdir to include-path)
168 ifelse($2,,CPPFLAGS,$2)="-I$cf_add_incdir $ifelse($2,,CPPFLAGS,[$]$2)"
169
170 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
171 test "$cf_top_incdir" = "$cf_add_incdir" && break
172 cf_add_incdir="$cf_top_incdir"
173 else
174 break
175 fi
176 fi
177 done
178 done
179fi
180])dnl
181dnl ---------------------------------------------------------------------------
182dnl CF_ADD_LIBDIR version: 6 updated: 2008/02/09 13:15:34
183dnl -------------
184dnl Adds to the library-path
185dnl
186dnl Some machines have trouble with multiple -L options.
187dnl
188dnl $1 is the (list of) directory(s) to add
189dnl $2 is the optional name of the variable to update (default LDFLAGS)
190dnl
191AC_DEFUN([CF_ADD_LIBDIR],
192[
193if test -n "$1" ; then
194 for cf_add_libdir in $1
195 do
196 if test $cf_add_libdir = /usr/lib ; then
197 :
198 elif test -d $cf_add_libdir
199 then
200 cf_have_libdir=no
201 if test -n "$LDFLAGS$LIBS" ; then
202 # a loop is needed to ensure we can add subdirs of existing dirs
203 for cf_test_libdir in $LDFLAGS $LIBS ; do
204 if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
205 cf_have_libdir=yes; break
206 fi
207 done
208 fi
209 if test "$cf_have_libdir" = no ; then
210 CF_VERBOSE(adding $cf_add_libdir to library-path)
211 ifelse($2,,LDFLAGS,$2)="-L$cf_add_libdir $ifelse($2,,LDFLAGS,[$]$2)"
212 fi
213 fi
214 done
215fi
216])dnl
217dnl ---------------------------------------------------------------------------
218dnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
219dnl ------------------
220dnl Append to a search-list for a nonstandard header/lib-file
221dnl $1 = the variable to return as result
222dnl $2 = the package name
223dnl $3 = the subdirectory, e.g., bin, include or lib
224dnl $4 = the directory under which we will test for subdirectories
225dnl $5 = a directory that we do not want $4 to match
226AC_DEFUN([CF_ADD_SUBDIR_PATH],
227[
228test "$4" != "$5" && \
229test -d "$4" && \
230ifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
231 test -n "$verbose" && echo " ... testing for $3-directories under $4"
232 test -d $4/$3 && $1="[$]$1 $4/$3"
233 test -d $4/$3/$2 && $1="[$]$1 $4/$3/$2"
234 test -d $4/$3/$2/$3 && $1="[$]$1 $4/$3/$2/$3"
235 test -d $4/$2/$3 && $1="[$]$1 $4/$2/$3"
236 test -d $4/$2/$3/$2 && $1="[$]$1 $4/$2/$3/$2"
237}
238])dnl
239dnl ---------------------------------------------------------------------------
240dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
241dnl ----------------
242dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
243dnl in the sharutils 4.2 distribution.
244AC_DEFUN([CF_ANSI_CC_CHECK],
245[
246AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
247cf_cv_ansi_cc=no
248cf_save_CFLAGS="$CFLAGS"
249cf_save_CPPFLAGS="$CPPFLAGS"
250# Don't try gcc -ansi; that turns off useful extensions and
251# breaks some systems' header files.
252# AIX -qlanglvl=ansi
253# Ultrix and OSF/1 -std1
254# HP-UX -Aa -D_HPUX_SOURCE
255# SVR4 -Xc
256# UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
257for cf_arg in "-DCC_HAS_PROTOS" \
258 "" \
259 -qlanglvl=ansi \
260 -std1 \
261 -Ae \
262 "-Aa -D_HPUX_SOURCE" \
263 -Xc
264do
265 CF_ADD_CFLAGS($cf_arg)
266 AC_TRY_COMPILE(
267[
268#ifndef CC_HAS_PROTOS
269#if !defined(__STDC__) || (__STDC__ != 1)
270choke me
271#endif
272#endif
273],[
274 int test (int i, double x);
275 struct s1 {int (*f) (int a);};
276 struct s2 {int (*f) (double a);};],
277 [cf_cv_ansi_cc="$cf_arg"; break])
278done
279CFLAGS="$cf_save_CFLAGS"
280CPPFLAGS="$cf_save_CPPFLAGS"
281])
282
283if test "$cf_cv_ansi_cc" != "no"; then
284if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
285 CF_ADD_CFLAGS($cf_cv_ansi_cc)
286else
287 AC_DEFINE(CC_HAS_PROTOS)
288fi
289fi
290])dnl
291dnl ---------------------------------------------------------------------------
292dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
293dnl ---------------
294dnl For programs that must use an ANSI compiler, obtain compiler options that
295dnl will make it recognize prototypes. We'll do preprocessor checks in other
296dnl macros, since tools such as unproto can fake prototypes, but only part of
297dnl the preprocessor.
298AC_DEFUN([CF_ANSI_CC_REQD],
299[AC_REQUIRE([CF_ANSI_CC_CHECK])
300if test "$cf_cv_ansi_cc" = "no"; then
301 AC_ERROR(
302[Your compiler does not appear to recognize prototypes.
303You have the following choices:
304 a. adjust your compiler options
305 b. get an up-to-date compiler
306 c. use a wrapper such as unproto])
307fi
308])dnl
309dnl ---------------------------------------------------------------------------
310dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
311dnl --------------
312dnl Allow user to disable a normally-on option.
313AC_DEFUN([CF_ARG_DISABLE],
314[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
315dnl ---------------------------------------------------------------------------
316dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
317dnl -------------
318dnl Allow user to enable a normally-off option.
319AC_DEFUN([CF_ARG_ENABLE],
320[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
321dnl ---------------------------------------------------------------------------
322dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
323dnl -------------
324dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
325dnl values.
326dnl
327dnl Parameters:
328dnl $1 = option name
329dnl $2 = help-string
330dnl $3 = action to perform if option is not default
331dnl $4 = action if perform if option is default
332dnl $5 = default option value (either 'yes' or 'no')
333AC_DEFUN([CF_ARG_OPTION],
334[AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
335 if test "$enableval" != "$5" ; then
336ifelse($3,,[ :]dnl
337,[ $3]) ifelse($4,,,[
338 else
339 $4])
340 fi],[enableval=$5 ifelse($4,,,[
341 $4
342])dnl
343 ])])dnl
344dnl ---------------------------------------------------------------------------
345dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
346dnl --------------
347dnl Check if we're accidentally using a cache from a different machine.
348dnl Derive the system name, as a check for reusing the autoconf cache.
349dnl
350dnl If we've packaged config.guess and config.sub, run that (since it does a
351dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
352dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
353dnl which is useful in cross-compiles.
354dnl
355dnl Note: we would use $ac_config_sub, but that is one of the places where
356dnl autoconf 2.5x broke compatibility with autoconf 2.13
357AC_DEFUN([CF_CHECK_CACHE],
358[
359if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
360 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
361 system_name="$host_os"
362else
363 system_name="`(uname -s -r) 2>/dev/null`"
364 if test -z "$system_name" ; then
365 system_name="`(hostname) 2>/dev/null`"
366 fi
367fi
368test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
369AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
370
371test -z "$system_name" && system_name="$cf_cv_system_name"
372test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
373
374if test ".$system_name" != ".$cf_cv_system_name" ; then
375 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
376 AC_ERROR("Please remove config.cache and try again.")
377fi
378])dnl
379dnl ---------------------------------------------------------------------------
380dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
381dnl ---------------
382dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
383dnl a build-configuration such as imake. These have the pitfall that they
384dnl often contain compiler-specific options which we cannot use, mixed with
385dnl preprocessor options that we usually can.
386AC_DEFUN([CF_CHECK_CFLAGS],
387[
388CF_VERBOSE(checking additions to CFLAGS)
389cf_check_cflags="$CFLAGS"
390cf_check_cppflags="$CPPFLAGS"
391CF_ADD_CFLAGS($1,yes)
392if test "$cf_check_cflags" != "$CFLAGS" ; then
393AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
394 [CF_VERBOSE(test-compile failed. Undoing change to \$CFLAGS)
395 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
396 CF_VERBOSE(but keeping change to \$CPPFLAGS)
397 fi
398 CFLAGS="$cf_check_flags"])
399fi
400])dnl
401dnl ---------------------------------------------------------------------------
402dnl CF_CURSES_ACS_MAP version: 3 updated: 2003/05/17 22:19:02
403dnl -----------------
404dnl Check for likely values of acs_map[]:
405AC_DEFUN([CF_CURSES_ACS_MAP],
406[
407AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
408cf_cv_curses_acs_map=unknown
409for name in acs_map _acs_map __acs_map _nc_acs_map
410do
411AC_TRY_LINK([
412#include <${cf_cv_ncurses_header-curses.h}>
413],[
414$name['k'] = ACS_PLUS
415],[cf_cv_curses_acs_map=$name; break])
416done
417])
418
419test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
420])
421dnl ---------------------------------------------------------------------------
422dnl CF_CURSES_CHECK_TYPE version: 2 updated: 2003/03/01 23:40:33
423dnl --------------------
424dnl Check if curses.h defines the given type
425AC_DEFUN([CF_CURSES_CHECK_TYPE],
426[
427AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header-curses.h})
428AC_TRY_COMPILE([
429#ifndef _XOPEN_SOURCE_EXTENDED
430#define _XOPEN_SOURCE_EXTENDED
431#endif
432#include <${cf_cv_ncurses_header-curses.h}>],[
433$1 foo
434],cf_result=yes,cf_result=no)
435AC_MSG_RESULT($cf_result)
436if test $cf_result = yes ; then
437 CF_UPPER(cf_result,have_type_$1)
438 AC_DEFINE_UNQUOTED($cf_result)
439else
440 AC_DEFINE_UNQUOTED($1,$2)
441fi
442])dnl
443dnl ---------------------------------------------------------------------------
444dnl CF_CURSES_CPPFLAGS version: 9 updated: 2006/02/04 19:44:43
445dnl ------------------
446dnl Look for the curses headers.
447AC_DEFUN([CF_CURSES_CPPFLAGS],[
448
449AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
450cf_cv_curses_incdir=no
451case $host_os in #(vi
452hpux10.*) #(vi
453 test -d /usr/include/curses_colr && \
454 cf_cv_curses_incdir="-I/usr/include/curses_colr"
455 ;;
456sunos3*|sunos4*)
457 test -d /usr/5lib && \
458 test -d /usr/5include && \
459 cf_cv_curses_incdir="-I/usr/5include"
460 ;;
461esac
462])
463test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
464
465CF_CURSES_HEADER
466CF_TERM_HEADER
467])dnl
468dnl ---------------------------------------------------------------------------
469dnl CF_CURSES_FUNCS version: 13 updated: 2007/04/28 09:15:55
470dnl ---------------
471dnl Curses-functions are a little complicated, since a lot of them are macros.
472AC_DEFUN([CF_CURSES_FUNCS],
473[
474AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
475AC_REQUIRE([CF_XOPEN_CURSES])
476AC_REQUIRE([CF_CURSES_TERM_H])
477for cf_func in $1
478do
479 CF_UPPER(cf_tr_func,$cf_func)
480 AC_MSG_CHECKING(for ${cf_func})
481 CF_MSG_LOG(${cf_func})
482 AC_CACHE_VAL(cf_cv_func_$cf_func,[
483 eval cf_result='$ac_cv_func_'$cf_func
484 if test ".$cf_result" != ".no"; then
485 AC_TRY_LINK([
486#ifdef HAVE_XCURSES
487#include <xcurses.h>
488char * XCursesProgramName = "test";
489#else
490#include <${cf_cv_ncurses_header-curses.h}>
491#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
492#include <ncursesw/term.h>
493#else
494#if defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
495#include <ncurses/term.h>
496#else
497#ifdef HAVE_TERM_H
498#include <term.h>
499#endif
500#endif
501#endif
502#endif],
503 [
504#ifndef ${cf_func}
505long foo = (long)(&${cf_func});
506${cf_cv_main_return-return}(foo == 0);
507#endif
508 ],
509 [cf_result=yes],
510 [cf_result=no])
511 fi
512 eval 'cf_cv_func_'$cf_func'=$cf_result'
513 ])
514 # use the computed/retrieved cache-value:
515 eval 'cf_result=$cf_cv_func_'$cf_func
516 AC_MSG_RESULT($cf_result)
517 if test $cf_result != no; then
518 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
519 fi
520done
521])dnl
522dnl ---------------------------------------------------------------------------
523dnl CF_CURSES_HEADER version: 1 updated: 2005/12/31 13:28:25
524dnl ----------------
525dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
526dnl variations of ncurses' installs.
527dnl
528dnl See also CF_NCURSES_HEADER, which sets the same cache variable.
529AC_DEFUN([CF_CURSES_HEADER],[
530AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
531cf_cv_ncurses_header=none
532for cf_header in \
533 curses.h \
534 ncurses.h \
535 ncurses/curses.h \
536 ncurses/ncurses.h
537do
538AC_TRY_COMPILE([#include <${cf_header}>],
539 [initscr(); tgoto("?", 0,0)],
540 [cf_cv_ncurses_header=$cf_header; break],[])
541done
542])
543
544if test "$cf_cv_ncurses_header" = none ; then
545 AC_MSG_ERROR(No curses header-files found)
546fi
547
548# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
549AC_CHECK_HEADERS($cf_cv_ncurses_header)
550])dnl
551dnl ---------------------------------------------------------------------------
552dnl CF_CURSES_LIBS version: 26 updated: 2007/07/29 10:32:40
553dnl --------------
554dnl Look for the curses libraries. Older curses implementations may require
555dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
556AC_DEFUN([CF_CURSES_LIBS],[
557
558AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
559AC_MSG_CHECKING(if we have identified curses libraries)
560AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
561 [initscr(); tgoto("?", 0,0)],
562 cf_result=yes,
563 cf_result=no)
564AC_MSG_RESULT($cf_result)
565
566if test "$cf_result" = no ; then
567case $host_os in #(vi
568freebsd*) #(vi
569 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
570 ;;
571hpux10.*) #(vi
572 AC_CHECK_LIB(cur_colr,initscr,[
573 LIBS="-lcur_colr $LIBS"
574 ac_cv_func_initscr=yes
575 ],[
576 AC_CHECK_LIB(Hcurses,initscr,[
577 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
578 LIBS="-lHcurses $LIBS"
579 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
580 ac_cv_func_initscr=yes
581 ])])
582 ;;
583linux*) # Suse Linux does not follow /usr/lib convention
584 CF_ADD_LIBDIR(/lib)
585 ;;
586sunos3*|sunos4*)
587 if test -d /usr/5lib ; then
588 CF_ADD_LIBDIR(/usr/5lib)
589 LIBS="$LIBS -lcurses -ltermcap"
590 fi
591 ac_cv_func_initscr=yes
592 ;;
593esac
594
595if test ".$ac_cv_func_initscr" != .yes ; then
596 cf_save_LIBS="$LIBS"
597 cf_term_lib=""
598 cf_curs_lib=""
599
600 if test ".${cf_cv_ncurses_version-no}" != .no
601 then
602 cf_check_list="ncurses curses cursesX"
603 else
604 cf_check_list="cursesX curses ncurses"
605 fi
606
607 # Check for library containing tgoto. Do this before curses library
608 # because it may be needed to link the test-case for initscr.
609 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
610 for cf_term_lib in $cf_check_list termcap termlib unknown
611 do
612 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
613 done
614 ])
615
616 # Check for library containing initscr
617 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
618 for cf_curs_lib in $cf_check_list xcurses jcurses unknown
619 do
620 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
621 done
622 test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
623
624 LIBS="-l$cf_curs_lib $cf_save_LIBS"
625 if test "$cf_term_lib" = unknown ; then
626 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
627 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
628 [initscr()],
629 [cf_result=yes],
630 [cf_result=no])
631 AC_MSG_RESULT($cf_result)
632 test $cf_result = no && AC_ERROR(Cannot link curses library)
633 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
634 :
635 elif test "$cf_term_lib" != predefined ; then
636 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
637 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
638 [initscr(); tgoto((char *)0, 0, 0);],
639 [cf_result=no],
640 [
641 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
642 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
643 [initscr()],
644 [cf_result=yes],
645 [cf_result=error])
646 ])
647 AC_MSG_RESULT($cf_result)
648 fi
649fi
650fi
651
652])dnl
653dnl ---------------------------------------------------------------------------
654dnl CF_CURSES_TERM_H version: 6 updated: 2003/11/06 19:59:57
655dnl ----------------
656dnl SVr4 curses should have term.h as well (where it puts the definitions of
657dnl the low-level interface). This may not be true in old/broken implementations,
658dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
659dnl running with Solaris 2.5.1).
660AC_DEFUN([CF_CURSES_TERM_H],
661[
662AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
663
664AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
665# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
666# for <term.h> if we do not find the variant.
667for cf_header in \
668 `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
669 term.h
670do
671 AC_TRY_COMPILE([
672#include <${cf_cv_ncurses_header-curses.h}>
673#include <${cf_header}>],
674 [WINDOW *x],
675 [cf_cv_term_header=$cf_header
676 break],
677 [cf_cv_term_header=no])
678done
679])
680
681case $cf_cv_term_header in #(vi
682term.h) #(vi
683 AC_DEFINE(HAVE_TERM_H)
684 ;;
685ncurses/term.h)
686 AC_DEFINE(HAVE_NCURSES_TERM_H)
687 ;;
688ncursesw/term.h)
689 AC_DEFINE(HAVE_NCURSESW_TERM_H)
690 ;;
691esac
692])dnl
693dnl ---------------------------------------------------------------------------
694dnl CF_CURSES_WACS_MAP version: 3 updated: 2003/05/17 22:19:02
695dnl ------------------
696dnl Check for likely values of wacs_map[]:
697AC_DEFUN([CF_CURSES_WACS_MAP],
698[
699AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
700 cf_cv_curses_wacs_map=unknown
701 for name in wacs_map _wacs_map __wacs_map _nc_wacs
702 do
703 AC_TRY_LINK([
704#ifndef _XOPEN_SOURCE_EXTENDED
705#define _XOPEN_SOURCE_EXTENDED
706#endif
707#include <${cf_cv_ncurses_header-curses.h}>],
708 [$name['k'] = *WACS_PLUS],
709 [cf_cv_curses_wacs_map=$name
710 break])
711 done])
712])
713dnl ---------------------------------------------------------------------------
714dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
715dnl ----------
716dnl "dirname" is not portable, so we fake it with a shell script.
717AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
718dnl ---------------------------------------------------------------------------
719dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11
720dnl ---------------
721dnl You can always use "make -n" to see the actual options, but it's hard to
722dnl pick out/analyze warning messages when the compile-line is long.
723dnl
724dnl Sets:
725dnl ECHO_LT - symbol to control if libtool is verbose
726dnl ECHO_LD - symbol to prefix "cc -o" lines
727dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
728dnl SHOW_CC - symbol to put before explicit "cc -c" lines
729dnl ECHO_CC - symbol to put before any "cc" line
730dnl
731AC_DEFUN([CF_DISABLE_ECHO],[
732AC_MSG_CHECKING(if you want to see long compiling messages)
733CF_ARG_DISABLE(echo,
734 [ --disable-echo display "compiling" commands],
735 [
736 ECHO_LT='--silent'
737 ECHO_LD='@echo linking [$]@;'
738 RULE_CC=' @echo compiling [$]<'
739 SHOW_CC=' @echo compiling [$]@'
740 ECHO_CC='@'
741],[
742 ECHO_LT=''
743 ECHO_LD=''
744 RULE_CC='# compiling'
745 SHOW_CC='# compiling'
746 ECHO_CC=''
747])
748AC_MSG_RESULT($enableval)
749AC_SUBST(ECHO_LT)
750AC_SUBST(ECHO_LD)
751AC_SUBST(RULE_CC)
752AC_SUBST(SHOW_CC)
753AC_SUBST(ECHO_CC)
754])dnl
755dnl ---------------------------------------------------------------------------
756dnl CF_ENABLE_WARNINGS version: 3 updated: 2003/05/24 14:24:29
757dnl ------------------
758dnl Configure-option to enable gcc warnings
759AC_DEFUN([CF_ENABLE_WARNINGS],[
760if ( test "$GCC" = yes || test "$GXX" = yes )
761then
762AC_MSG_CHECKING(if you want to turn on gcc warnings)
763CF_ARG_ENABLE(warnings,
764 [ --enable-warnings test: turn on gcc compiler warnings],
765 [with_warnings=yes],
766 [with_warnings=no])
767AC_MSG_RESULT($with_warnings)
768if test "$with_warnings" = "yes"
769then
770 CF_GCC_WARNINGS
771fi
772fi
773])dnl
774dnl ---------------------------------------------------------------------------
775dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
776dnl ---------------
777dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
778dnl prefer a standard location, and use -L options only if we do not find the
779dnl library in the standard library location(s).
780dnl $1 = library name
781dnl $2 = library class, usually the same as library name
782dnl $3 = includes
783dnl $4 = code fragment to compile/link
784dnl $5 = corresponding function-name
785dnl $6 = flag, nonnull if failure should not cause an error-exit
786dnl
787dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
788dnl to use a -L option.
789AC_DEFUN([CF_FIND_LIBRARY],
790[
791 eval 'cf_cv_have_lib_'$1'=no'
792 cf_libdir=""
793 AC_CHECK_FUNC($5,
794 eval 'cf_cv_have_lib_'$1'=yes',[
795 cf_save_LIBS="$LIBS"
796 AC_MSG_CHECKING(for $5 in -l$1)
797 LIBS="-l$1 $LIBS"
798 AC_TRY_LINK([$3],[$4],
799 [AC_MSG_RESULT(yes)
800 eval 'cf_cv_have_lib_'$1'=yes'
801 ],
802 [AC_MSG_RESULT(no)
803 CF_LIBRARY_PATH(cf_search,$2)
804 for cf_libdir in $cf_search
805 do
806 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
807 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
808 AC_TRY_LINK([$3],[$4],
809 [AC_MSG_RESULT(yes)
810 eval 'cf_cv_have_lib_'$1'=yes'
811 break],
812 [AC_MSG_RESULT(no)
813 LIBS="$cf_save_LIBS"])
814 done
815 ])
816 ])
817eval 'cf_found_library=[$]cf_cv_have_lib_'$1
818ifelse($6,,[
819if test $cf_found_library = no ; then
820 AC_ERROR(Cannot link $1 library)
821fi
822])
823])dnl
824dnl ---------------------------------------------------------------------------
825dnl CF_FUNC_CURSES_VERSION version: 4 updated: 2007/04/28 09:15:55
826dnl ----------------------
827dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
828dnl It's a character string "SVR4", not documented.
829AC_DEFUN([CF_FUNC_CURSES_VERSION],
830[
831AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
832AC_TRY_RUN([
833#include <${cf_cv_ncurses_header-curses.h}>
834int main()
835{
836 char temp[1024];
837 sprintf(temp, "%s\n", curses_version());
838 ${cf_cv_main_return-return}(0);
839}]
840,[cf_cv_func_curses_version=yes]
841,[cf_cv_func_curses_version=no]
842,[cf_cv_func_curses_version=unknown])
843rm -f core])
844test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
845])
846dnl ---------------------------------------------------------------------------
847dnl CF_GCC_ATTRIBUTES version: 11 updated: 2007/07/29 09:55:12
848dnl -----------------
849dnl Test for availability of useful gcc __attribute__ directives to quiet
850dnl compiler warnings. Though useful, not all are supported -- and contrary
851dnl to documentation, unrecognized directives cause older compilers to barf.
852AC_DEFUN([CF_GCC_ATTRIBUTES],
853[
854if test "$GCC" = yes
855then
856cat > conftest.i <<EOF
857#ifndef GCC_PRINTF
858#define GCC_PRINTF 0
859#endif
860#ifndef GCC_SCANF
861#define GCC_SCANF 0
862#endif
863#ifndef GCC_NORETURN
864#define GCC_NORETURN /* nothing */
865#endif
866#ifndef GCC_UNUSED
867#define GCC_UNUSED /* nothing */
868#endif
869EOF
870if test "$GCC" = yes
871then
872 AC_CHECKING([for $CC __attribute__ directives])
873cat > conftest.$ac_ext <<EOF
874#line __oline__ "${as_me-configure}"
875#include "confdefs.h"
876#include "conftest.h"
877#include "conftest.i"
878#if GCC_PRINTF
879#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
880#else
881#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
882#endif
883#if GCC_SCANF
884#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
885#else
886#define GCC_SCANFLIKE(fmt,var) /*nothing*/
887#endif
888extern void wow(char *,...) GCC_SCANFLIKE(1,2);
889extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
890extern void foo(void) GCC_NORETURN;
891int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
892EOF
893 for cf_attribute in scanf printf unused noreturn
894 do
895 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
896 cf_directive="__attribute__(($cf_attribute))"
897 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
898 case $cf_attribute in
899 scanf|printf)
900 cat >conftest.h <<EOF
901#define GCC_$cf_ATTRIBUTE 1
902EOF
903 ;;
904 *)
905 cat >conftest.h <<EOF
906#define GCC_$cf_ATTRIBUTE $cf_directive
907EOF
908 ;;
909 esac
910 if AC_TRY_EVAL(ac_compile); then
911 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
912 cat conftest.h >>confdefs.h
913 fi
914 done
915else
916 fgrep define conftest.i >>confdefs.h
917fi
918rm -rf conftest*
919fi
920])dnl
921dnl ---------------------------------------------------------------------------
922dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
923dnl --------------
924dnl Find version of gcc
925AC_DEFUN([CF_GCC_VERSION],[
926AC_REQUIRE([AC_PROG_CC])
927GCC_VERSION=none
928if test "$GCC" = yes ; then
929 AC_MSG_CHECKING(version of $CC)
930 GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
931 test -z "$GCC_VERSION" && GCC_VERSION=unknown
932 AC_MSG_RESULT($GCC_VERSION)
933fi
934])dnl
935dnl ---------------------------------------------------------------------------
936dnl CF_GCC_WARNINGS version: 22 updated: 2007/07/29 09:55:12
937dnl ---------------
938dnl Check if the compiler supports useful warning options. There's a few that
939dnl we don't use, simply because they're too noisy:
940dnl
941dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
942dnl -Wredundant-decls (system headers make this too noisy)
943dnl -Wtraditional (combines too many unrelated messages, only a few useful)
944dnl -Wwrite-strings (too noisy, but should review occasionally). This
945dnl is enabled for ncurses using "--enable-const".
946dnl -pedantic
947dnl
948dnl Parameter:
949dnl $1 is an optional list of gcc warning flags that a particular
950dnl application might want to use, e.g., "no-unused" for
951dnl -Wno-unused
952dnl Special:
953dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
954dnl
955AC_DEFUN([CF_GCC_WARNINGS],
956[
957AC_REQUIRE([CF_GCC_VERSION])
958CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
959
960cat > conftest.$ac_ext <<EOF
961#line __oline__ "${as_me-configure}"
962int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
963EOF
964
965if test "$INTEL_COMPILER" = yes
966then
967# The "-wdXXX" options suppress warnings:
968# remark #1419: external declaration in primary source file
969# remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
970# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
971# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
972# remark #193: zero used for undefined preprocessing identifier
973# remark #593: variable "curs_sb_left_arrow" was set but never used
974# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
975# remark #869: parameter "tw" was never referenced
976# remark #981: operands are evaluated in unspecified order
977# warning #269: invalid format string conversion
978
979 AC_CHECKING([for $CC warning options])
980 cf_save_CFLAGS="$CFLAGS"
981 EXTRA_CFLAGS="-Wall"
982 for cf_opt in \
983 wd1419 \
984 wd1682 \
985 wd1683 \
986 wd1684 \
987 wd193 \
988 wd279 \
989 wd593 \
990 wd810 \
991 wd869 \
992 wd981
993 do
994 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
995 if AC_TRY_EVAL(ac_compile); then
996 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
997 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
998 fi
999 done
1000 CFLAGS="$cf_save_CFLAGS"
1001
1002elif test "$GCC" = yes
1003then
1004 AC_CHECKING([for $CC warning options])
1005 cf_save_CFLAGS="$CFLAGS"
1006 EXTRA_CFLAGS="-W -Wall"
1007 cf_warn_CONST=""
1008 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1009 for cf_opt in \
1010 Wbad-function-cast \
1011 Wcast-align \
1012 Wcast-qual \
1013 Winline \
1014 Wmissing-declarations \
1015 Wmissing-prototypes \
1016 Wnested-externs \
1017 Wpointer-arith \
1018 Wshadow \
1019 Wstrict-prototypes \
1020 Wundef $cf_warn_CONST $1
1021 do
1022 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1023 if AC_TRY_EVAL(ac_compile); then
1024 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1025 case $cf_opt in #(vi
1026 Wcast-qual) #(vi
1027 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1028 ;;
1029 Winline) #(vi
1030 case $GCC_VERSION in
1031 3.3*)
1032 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1033 continue;;
1034 esac
1035 ;;
1036 esac
1037 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1038 fi
1039 done
1040 CFLAGS="$cf_save_CFLAGS"
1041fi
1042rm -f conftest*
1043
1044AC_SUBST(EXTRA_CFLAGS)
1045])dnl
1046dnl ---------------------------------------------------------------------------
1047dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1048dnl -------------
1049dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1050dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
1051dnl (or misfeature) of glibc2, which breaks portability of many applications,
1052dnl since it is interwoven with GNU extensions.
1053dnl
1054dnl Well, yes we could work around it...
1055AC_DEFUN([CF_GNU_SOURCE],
1056[
1057AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1058AC_TRY_COMPILE([#include <sys/types.h>],[
1059#ifndef _XOPEN_SOURCE
1060make an error
1061#endif],
1062 [cf_cv_gnu_source=no],
1063 [cf_save="$CPPFLAGS"
1064 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1065 AC_TRY_COMPILE([#include <sys/types.h>],[
1066#ifdef _XOPEN_SOURCE
1067make an error
1068#endif],
1069 [cf_cv_gnu_source=no],
1070 [cf_cv_gnu_source=yes])
1071 CPPFLAGS="$cf_save"
1072 ])
1073])
1074test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1075])dnl
1076dnl ---------------------------------------------------------------------------
1077dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
1078dnl --------------
1079dnl Construct a search-list for a nonstandard header-file
1080AC_DEFUN([CF_HEADER_PATH],
1081[CF_SUBDIR_PATH($1,$2,include)
1082test "$includedir" != NONE && \
1083test "$includedir" != "/usr/include" && \
1084test -d "$includedir" && {
1085 test -d $includedir && $1="[$]$1 $includedir"
1086 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1087}
1088
1089test "$oldincludedir" != NONE && \
1090test "$oldincludedir" != "/usr/include" && \
1091test -d "$oldincludedir" && {
1092 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
1093 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1094}
1095
1096])dnl
1097dnl ---------------------------------------------------------------------------
1098dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
1099dnl -----------------
1100dnl If we do not have a given script, look for it in the parent directory.
1101AC_DEFUN([CF_INHERIT_SCRIPT],
1102[
1103test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1104])dnl
1105dnl ---------------------------------------------------------------------------
1106dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
1107dnl -----------------
1108dnl Check if the given compiler is really the Intel compiler for Linux. It
1109dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1110dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1111dnl
1112dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1113dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
1114dnl the wrappers for gcc and g++ warnings.
1115dnl
1116dnl $1 = GCC (default) or GXX
1117dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1118dnl $3 = CFLAGS (default) or CXXFLAGS
1119AC_DEFUN([CF_INTEL_COMPILER],[
1120ifelse($2,,INTEL_COMPILER,[$2])=no
1121
1122if test "$ifelse($1,,[$1],GCC)" = yes ; then
1123 case $host_os in
1124 linux*|gnu*)
1125 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
1126 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
1127 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
1128 AC_TRY_COMPILE([],[
1129#ifdef __INTEL_COMPILER
1130#else
1131make an error
1132#endif
1133],[ifelse($2,,INTEL_COMPILER,[$2])=yes
1134cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1135],[])
1136 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
1137 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
1138 ;;
1139 esac
1140fi
1141])dnl
1142dnl ---------------------------------------------------------------------------
1143dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
1144dnl ---------------
1145dnl Construct a search-list for a nonstandard library-file
1146AC_DEFUN([CF_LIBRARY_PATH],
1147[CF_SUBDIR_PATH($1,$2,lib)])dnl
1148dnl ---------------------------------------------------------------------------
1149dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
1150dnl ----------
1151dnl Write a debug message to config.log, along with the line number in the
1152dnl configure script.
1153AC_DEFUN([CF_MSG_LOG],[
1154echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1155])dnl
1156dnl ---------------------------------------------------------------------------
1157dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1158dnl -------------------
1159dnl Check if we can compile with ncurses' header file
1160dnl $1 is the cache variable to set
1161dnl $2 is the header-file to include
1162dnl $3 is the root name (ncurses or ncursesw)
1163AC_DEFUN([CF_NCURSES_CC_CHECK],[
1164 AC_TRY_COMPILE([
1165]ifelse($3,ncursesw,[
1166#define _XOPEN_SOURCE_EXTENDED
1167#undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
1168#define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
1169])[
1170#include <$2>],[
1171#ifdef NCURSES_VERSION
1172]ifelse($3,ncursesw,[
1173#ifndef WACS_BSSB
1174 make an error
1175#endif
1176])[
1177printf("%s\n", NCURSES_VERSION);
1178#else
1179#ifdef __NCURSES_H
1180printf("old\n");
1181#else
1182 make an error
1183#endif
1184#endif
1185 ]
1186 ,[$1=$2]
1187 ,[$1=no])
1188])dnl
1189dnl ---------------------------------------------------------------------------
1190dnl CF_NCURSES_CPPFLAGS version: 19 updated: 2007/07/29 13:35:20
1191dnl -------------------
1192dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1193dnl the CPPFLAGS variable so we can include its header.
1194dnl
1195dnl The header files may be installed as either curses.h, or ncurses.h (would
1196dnl be obsolete, except that some packagers prefer this name to distinguish it
1197dnl from a "native" curses implementation). If not installed for overwrite,
1198dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1199dnl /usr/include/ncurses), but someone may have installed overwriting the
1200dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
1201dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1202dnl the header.
1203dnl
1204dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1205dnl is already in the include-path, don't even bother with this, since we cannot
1206dnl easily determine which file it is. In this case, it has to be <curses.h>.
1207dnl
1208dnl The optional parameter gives the root name of the library, in case it is
1209dnl not installed as the default curses library. That is how the
1210dnl wide-character version of ncurses is installed.
1211AC_DEFUN([CF_NCURSES_CPPFLAGS],
1212[AC_REQUIRE([CF_WITH_CURSES_DIR])
1213
1214AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1215cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1216
1217test -n "$cf_cv_curses_dir" && \
1218test "$cf_cv_curses_dir" != "no" && { \
1219 CF_ADD_INCDIR($cf_cv_curses_dir/include $cf_cv_curses_dir/include/$cf_ncuhdr_root)
1220}
1221
1222AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1223 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1224 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1225 for cf_header in $cf_header_list
1226 do
1227 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1228 test "$cf_cv_ncurses_h" != no && break
1229 done
1230])
1231
1232CF_NCURSES_HEADER
1233CF_TERM_HEADER
1234
1235# some applications need this, but should check for NCURSES_VERSION
1236AC_DEFINE(NCURSES)
1237
1238CF_NCURSES_VERSION
1239])dnl
1240dnl ---------------------------------------------------------------------------
1241dnl CF_NCURSES_HEADER version: 1 updated: 2005/12/31 13:28:37
1242dnl -----------------
1243dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1244dnl variations of ncurses' installs.
1245dnl
1246dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1247AC_DEFUN([CF_NCURSES_HEADER],[
1248
1249if test "$cf_cv_ncurses_h" != no ; then
1250 cf_cv_ncurses_header=$cf_cv_ncurses_h
1251else
1252
1253AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1254 test -n "$verbose" && echo
1255 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1256 test -n "$verbose" && echo search path $cf_search
1257 cf_save2_CPPFLAGS="$CPPFLAGS"
1258 for cf_incdir in $cf_search
1259 do
1260 CF_ADD_INCDIR($cf_incdir)
1261 for cf_header in \
1262 ncurses.h \
1263 curses.h
1264 do
1265 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1266 if test "$cf_cv_ncurses_h2" != no ; then
1267 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1268 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
1269 break
1270 fi
1271 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1272 done
1273 CPPFLAGS="$cf_save2_CPPFLAGS"
1274 test "$cf_cv_ncurses_h2" != no && break
1275 done
1276 test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found)
1277 ])
1278
1279 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1280 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1281 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1282 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1283 fi
1284 CF_ADD_INCDIR($cf_1st_incdir)
1285
1286fi
1287
1288# Set definitions to allow ifdef'ing for ncurses.h
1289
1290case $cf_cv_ncurses_header in # (vi
1291*ncurses.h)
1292 AC_DEFINE(HAVE_NCURSES_H)
1293 ;;
1294esac
1295
1296case $cf_cv_ncurses_header in # (vi
1297ncurses/curses.h|ncurses/ncurses.h)
1298 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1299 ;;
1300ncursesw/curses.h|ncursesw/ncurses.h)
1301 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1302 ;;
1303esac
1304
1305])dnl
1306dnl ---------------------------------------------------------------------------
1307dnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
1308dnl ---------------
1309dnl Look for the ncurses library. This is a little complicated on Linux,
1310dnl because it may be linked with the gpm (general purpose mouse) library.
1311dnl Some distributions have gpm linked with (bsd) curses, which makes it
1312dnl unusable with ncurses. However, we don't want to link with gpm unless
1313dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1314dnl and the linker will record a dependency.
1315dnl
1316dnl The optional parameter gives the root name of the library, in case it is
1317dnl not installed as the default curses library. That is how the
1318dnl wide-character version of ncurses is installed.
1319AC_DEFUN([CF_NCURSES_LIBS],
1320[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1321
1322cf_nculib_root=ifelse($1,,ncurses,$1)
1323 # This works, except for the special case where we find gpm, but
1324 # ncurses is in a nonstandard location via $LIBS, and we really want
1325 # to link gpm.
1326cf_ncurses_LIBS=""
1327cf_ncurses_SAVE="$LIBS"
1328AC_CHECK_LIB(gpm,Gpm_Open,
1329 [AC_CHECK_LIB(gpm,initscr,
1330 [LIBS="$cf_ncurses_SAVE"],
1331 [cf_ncurses_LIBS="-lgpm"])])
1332
1333case $host_os in #(vi
1334freebsd*)
1335 # This is only necessary if you are linking against an obsolete
1336 # version of ncurses (but it should do no harm, since it's static).
1337 if test "$cf_nculib_root" = ncurses ; then
1338 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1339 fi
1340 ;;
1341esac
1342
1343LIBS="$cf_ncurses_LIBS $LIBS"
1344
1345if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1346then
1347 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
1348 LIBS="-l$cf_nculib_root $LIBS"
1349else
1350 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1351 [#include <${cf_cv_ncurses_header-curses.h}>],
1352 [initscr()],
1353 initscr)
1354fi
1355
1356if test -n "$cf_ncurses_LIBS" ; then
1357 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1358 cf_ncurses_SAVE="$LIBS"
1359 for p in $cf_ncurses_LIBS ; do
1360 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1361 if test "$q" != "$LIBS" ; then
1362 LIBS="$q"
1363 fi
1364 done
1365 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1366 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1367 [AC_MSG_RESULT(yes)],
1368 [AC_MSG_RESULT(no)
1369 LIBS="$cf_ncurses_SAVE"])
1370fi
1371
1372CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1373AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1374])dnl
1375dnl ---------------------------------------------------------------------------
1376dnl CF_NCURSES_VERSION version: 12 updated: 2007/04/28 09:15:55
1377dnl ------------------
1378dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1379dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
1380dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1381AC_DEFUN([CF_NCURSES_VERSION],
1382[
1383AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1384AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1385 cf_cv_ncurses_version=no
1386 cf_tempfile=out$$
1387 rm -f $cf_tempfile
1388 AC_TRY_RUN([
1389#include <${cf_cv_ncurses_header-curses.h}>
1390#include <stdio.h>
1391int main()
1392{
1393 FILE *fp = fopen("$cf_tempfile", "w");
1394#ifdef NCURSES_VERSION
1395# ifdef NCURSES_VERSION_PATCH
1396 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1397# else
1398 fprintf(fp, "%s\n", NCURSES_VERSION);
1399# endif
1400#else
1401# ifdef __NCURSES_H
1402 fprintf(fp, "old\n");
1403# else
1404 make an error
1405# endif
1406#endif
1407 ${cf_cv_main_return-return}(0);
1408}],[
1409 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1410
1411 # This will not work if the preprocessor splits the line after the
1412 # Autoconf token. The 'unproto' program does that.
1413 cat > conftest.$ac_ext <<EOF
1414#include <${cf_cv_ncurses_header-curses.h}>
1415#undef Autoconf
1416#ifdef NCURSES_VERSION
1417Autoconf NCURSES_VERSION
1418#else
1419#ifdef __NCURSES_H
1420Autoconf "old"
1421#endif
1422;
1423#endif
1424EOF
1425 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1426 AC_TRY_EVAL(cf_try)
1427 if test -f conftest.out ; then
1428 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1429 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1430 rm -f conftest.out
1431 fi
1432])
1433 rm -f $cf_tempfile
1434])
1435test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1436])dnl
1437dnl ---------------------------------------------------------------------------
1438dnl CF_PATH_SYNTAX version: 11 updated: 2006/09/02 08:55:46
1439dnl --------------
1440dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1441dnl begins with one of the prefix/exec_prefix variables, and then again if the
1442dnl result begins with 'NONE'. This is necessary to work around autoconf's
1443dnl delayed evaluation of those symbols.
1444AC_DEFUN([CF_PATH_SYNTAX],[
1445if test "x$prefix" != xNONE; then
1446 cf_path_syntax="$prefix"
1447else
1448 cf_path_syntax="$ac_default_prefix"
1449fi
1450
1451case ".[$]$1" in #(vi
1452.\[$]\(*\)*|.\'*\'*) #(vi
1453 ;;
1454..|./*|.\\*) #(vi
1455 ;;
1456.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1457 ;;
1458.\[$]{*prefix}*) #(vi
1459 eval $1="[$]$1"
1460 case ".[$]$1" in #(vi
1461 .NONE/*)
1462 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1463 ;;
1464 esac
1465 ;; #(vi
1466.no|.NONE/*)
1467 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1468 ;;
1469*)
1470 ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1471 ;;
1472esac
1473])dnl
1474dnl ---------------------------------------------------------------------------
1475dnl CF_PDCURSES_X11 version: 7 updated: 2006/11/12 17:31:59
1476dnl ---------------
1477dnl Configure for PDCurses' X11 library
1478AC_DEFUN([CF_PDCURSES_X11],[
1479AC_REQUIRE([CF_X_ATHENA])
1480
1481AC_PATH_PROGS(XCURSES_CONFIG,xcurses-config,none)
1482
1483if test "$XCURSES_CONFIG" != none ; then
1484
1485CPPFLAGS="`$XCURSES_CONFIG --cflags` $CPPFLAGS"
1486LIBS="`$XCURSES_CONFIG --libs` $LIBS"
1487
1488cf_cv_lib_XCurses=yes
1489
1490else
1491
1492LDFLAGS="$LDFLAGS $X_LIBS"
1493CF_CHECK_CFLAGS($X_CFLAGS)
1494AC_CHECK_LIB(X11,XOpenDisplay,
1495 [LIBS="-lX11 $LIBS"],,
1496 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
1497AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
1498LIBS="-lXCurses $LIBS"
1499AC_TRY_LINK([
1500#include <xcurses.h>
1501char *XCursesProgramName = "test";
1502],[XCursesExit();],
1503[cf_cv_lib_XCurses=yes],
1504[cf_cv_lib_XCurses=no])
1505])
1506
1507fi
1508
1509if test $cf_cv_lib_XCurses = yes ; then
1510 AC_DEFINE(UNIX)
1511 AC_DEFINE(XCURSES)
1512 AC_DEFINE(HAVE_XCURSES)
1513else
1514 AC_ERROR(Cannot link with XCurses)
1515fi
1516])dnl
1517dnl ---------------------------------------------------------------------------
1518dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1519dnl -----------------
1520dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1521dnl
1522dnl POSIX.1-1990 _POSIX_SOURCE
1523dnl POSIX.1-1990 and _POSIX_SOURCE and
1524dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1525dnl Bindings Option
1526dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1527dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1528dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1529dnl
1530dnl Parameters:
1531dnl $1 is the nominal value for _POSIX_C_SOURCE
1532AC_DEFUN([CF_POSIX_C_SOURCE],
1533[
1534cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1535
1536cf_save_CFLAGS="$CFLAGS"
1537cf_save_CPPFLAGS="$CPPFLAGS"
1538
1539CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1540CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1541
1542AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1543 CF_MSG_LOG(if the symbol is already defined go no further)
1544 AC_TRY_COMPILE([#include <sys/types.h>],[
1545#ifndef _POSIX_C_SOURCE
1546make an error
1547#endif],
1548 [cf_cv_posix_c_source=no],
1549 [cf_want_posix_source=no
1550 case .$cf_POSIX_C_SOURCE in #(vi
1551 .[[12]]??*) #(vi
1552 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1553 ;;
1554 .2) #(vi
1555 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1556 cf_want_posix_source=yes
1557 ;;
1558 .*)
1559 cf_want_posix_source=yes
1560 ;;
1561 esac
1562 if test "$cf_want_posix_source" = yes ; then
1563 AC_TRY_COMPILE([#include <sys/types.h>],[
1564#ifdef _POSIX_SOURCE
1565make an error
1566#endif],[],
1567 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1568 fi
1569 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1570 CFLAGS="$cf_trim_CFLAGS"
1571 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1572 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1573 AC_TRY_COMPILE([#include <sys/types.h>],[
1574#ifndef _POSIX_C_SOURCE
1575make an error
1576#endif],,
1577 [cf_cv_posix_c_source=no])
1578 CFLAGS="$cf_save_CFLAGS"
1579 CPPFLAGS="$cf_save_CPPFLAGS"
1580 ])
1581])
1582
1583if test "$cf_cv_posix_c_source" != no ; then
1584 CFLAGS="$cf_trim_CFLAGS"
1585 CPPFLAGS="$cf_trim_CPPFLAGS"
1586 if test "$cf_cv_cc_u_d_options" = yes ; then
1587 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1588 sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'`
1589 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1590 fi
1591 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1592fi
1593
1594])dnl
1595dnl ---------------------------------------------------------------------------
1596dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
1597dnl ------------
1598dnl Append definitions and rules for the given programs to the subdirectory
1599dnl Makefiles, and the recursion rule for the top-level Makefile.
1600dnl
1601dnl parameters
1602dnl $1 = script to run
1603dnl $2 = list of subdirectories
1604dnl
1605dnl variables
1606dnl $AWK
1607AC_DEFUN([CF_PRG_RULES],
1608[
1609for cf_dir in $2
1610do
1611 if test ! -d $srcdir/$cf_dir; then
1612 continue
1613 elif test -f $srcdir/$cf_dir/programs; then
1614 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
1615 fi
1616done
1617
1618])dnl
1619dnl ---------------------------------------------------------------------------
1620dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1621dnl --------------
1622dnl Check if C (preprocessor) -U and -D options are processed in the order
1623dnl given rather than by type of option. Some compilers insist on apply all
1624dnl of the -U options after all of the -D options. Others allow mixing them,
1625dnl and may predefine symbols that conflict with those we define.
1626AC_DEFUN([CF_PROG_CC_U_D],
1627[
1628AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1629 cf_save_CPPFLAGS="$CPPFLAGS"
1630 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1631 AC_TRY_COMPILE([],[
1632#ifndef U_D_OPTIONS
1633make an undefined-error
1634#endif
1635#ifdef D_U_OPTIONS
1636make a defined-error
1637#endif
1638 ],[
1639 cf_cv_cc_u_d_options=yes],[
1640 cf_cv_cc_u_d_options=no])
1641 CPPFLAGS="$cf_save_CPPFLAGS"
1642])
1643])dnl
1644dnl ---------------------------------------------------------------------------
1645dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1646dnl ----------------
1647dnl Remove all -U and -D options that refer to the given symbol from a list
1648dnl of C compiler options. This works around the problem that not all
1649dnl compilers process -U and -D options from left-to-right, so a -U option
1650dnl cannot be used to cancel the effect of a preceding -D option.
1651dnl
1652dnl $1 = target (which could be the same as the source variable)
1653dnl $2 = source (including '$')
1654dnl $3 = symbol to remove
1655define([CF_REMOVE_DEFINE],
1656[
1657# remove $3 symbol from $2
1658$1=`echo "$2" | \
1659 sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \
1660 -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'`
1661])dnl
1662dnl ---------------------------------------------------------------------------
1663dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
1664dnl ---------------
1665dnl signal handler, but there are some gcc depedencies in that recommendation.
1666dnl Try anyway.
1667AC_DEFUN([CF_SIG_ATOMIC_T],
1668[
1669AC_MSG_CHECKING(for signal global datatype)
1670AC_CACHE_VAL(cf_cv_sig_atomic_t,[
1671 for cf_type in \
1672 "volatile sig_atomic_t" \
1673 "sig_atomic_t" \
1674 "int"
1675 do
1676 AC_TRY_COMPILE([
1677#include <sys/types.h>
1678#include <signal.h>
1679#include <stdio.h>
1680
1681extern $cf_type x;
1682$cf_type x;
1683static void handler(int sig)
1684{
1685 x = 5;
1686}],
1687 [signal(SIGINT, handler);
1688 x = 1],
1689 [cf_cv_sig_atomic_t=$cf_type],
1690 [cf_cv_sig_atomic_t=no])
1691 test "$cf_cv_sig_atomic_t" != no && break
1692 done
1693 ])
1694AC_MSG_RESULT($cf_cv_sig_atomic_t)
1695test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
1696])dnl
1697dnl ---------------------------------------------------------------------------
1698dnl CF_SUBDIR_PATH version: 5 updated: 2007/07/29 09:55:12
1699dnl --------------
1700dnl Construct a search-list for a nonstandard header/lib-file
1701dnl $1 = the variable to return as result
1702dnl $2 = the package name
1703dnl $3 = the subdirectory, e.g., bin, include or lib
1704AC_DEFUN([CF_SUBDIR_PATH],
1705[$1=""
1706
1707CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
1708CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
1709CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
1710CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
1711CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
1712])dnl
1713dnl ---------------------------------------------------------------------------
1714dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1715dnl ------------------
1716dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1717dnl older SCO configurations.
1718AC_DEFUN([CF_SYS_TIME_SELECT],
1719[
1720AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1721AC_CACHE_VAL(cf_cv_sys_time_select,[
1722AC_TRY_COMPILE([
1723#include <sys/types.h>
1724#ifdef HAVE_SYS_TIME_H
1725#include <sys/time.h>
1726#endif
1727#ifdef HAVE_SYS_SELECT_H
1728#include <sys/select.h>
1729#endif
1730],[],[cf_cv_sys_time_select=yes],
1731 [cf_cv_sys_time_select=no])
1732 ])
1733AC_MSG_RESULT($cf_cv_sys_time_select)
1734test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1735])dnl
1736dnl ---------------------------------------------------------------------------
1737dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
1738dnl --------------
1739dnl Look for term.h, which is part of X/Open curses. It defines the interface
1740dnl to terminfo database. Usually it is in the same include-path as curses.h,
1741dnl but some packagers change this, breaking various applications.
1742AC_DEFUN([CF_TERM_HEADER],[
1743AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
1744case ${cf_cv_ncurses_header} in #(vi
1745*/ncurses.h|*/ncursesw.h) #(vi
1746 cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
1747 ;;
1748*)
1749 cf_term_header=term.h
1750 ;;
1751esac
1752
1753for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
1754do
1755AC_TRY_COMPILE([#include <stdio.h>
1756#include <${cf_cv_ncurses_header-curses.h}>
1757#include <$cf_test>
1758],[int x = auto_left_margin],[
1759 cf_cv_term_header="$cf_test"],[
1760 cf_cv_term_header=unknown
1761 ])
1762 test "$cf_cv_term_header" != unknown && break
1763done
1764])
1765
1766# Set definitions to allow ifdef'ing to accommodate subdirectories
1767
1768case $cf_cv_term_header in # (vi
1769*term.h)
1770 AC_DEFINE(HAVE_TERM_H)
1771 ;;
1772esac
1773
1774case $cf_cv_term_header in # (vi
1775ncurses/term.h) #(vi
1776 AC_DEFINE(HAVE_NCURSES_TERM_H)
1777 ;;
1778ncursesw/term.h)
1779 AC_DEFINE(HAVE_NCURSESW_TERM_H)
1780 ;;
1781esac
1782])dnl
1783dnl ---------------------------------------------------------------------------
1784dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1785dnl --------
1786dnl Make an uppercase version of a variable
1787dnl $1=uppercase($2)
1788AC_DEFUN([CF_UPPER],
1789[
1790$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1791])dnl
1792dnl ---------------------------------------------------------------------------
1793dnl CF_UTF8_LIB version: 4 updated: 2003/03/01 18:36:42
1794dnl -----------
1795dnl Check for multibyte support, and if not found, utf8 compatibility library
1796AC_DEFUN([CF_UTF8_LIB],
1797[
1798AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
1799 cf_save_LIBS="$LIBS"
1800 AC_TRY_LINK([
1801#include <stdlib.h>],[putwc(0,0);],
1802 [cf_cv_utf8_lib=yes],
1803 [LIBS="-lutf8 $LIBS"
1804 AC_TRY_LINK([
1805#include <libutf8.h>],[putwc(0,0);],
1806 [cf_cv_utf8_lib=add-on],
1807 [cf_cv_utf8_lib=no])
1808 LIBS="$cf_save_LIBS"
1809])])
1810
1811# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
1812# ncurses/ncursesw:
1813if test "$cf_cv_utf8_lib" = "add-on" ; then
1814 AC_DEFINE(HAVE_LIBUTF8_H)
1815 LIBS="-lutf8 $LIBS"
1816fi
1817])dnl
1818dnl ---------------------------------------------------------------------------
1819dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1820dnl ----------
1821dnl Use AC_VERBOSE w/o the warnings
1822AC_DEFUN([CF_VERBOSE],
1823[test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1824CF_MSG_LOG([$1])
1825])dnl
1826dnl ---------------------------------------------------------------------------
1827dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
1828dnl ------------------
1829dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
1830dnl libraries.
1831AC_DEFUN([CF_WITH_CURSES_DIR],[
1832AC_ARG_WITH(curses-dir,
1833 [ --with-curses-dir=DIR directory in which (n)curses is installed],
1834 [CF_PATH_SYNTAX(withval)
1835 cf_cv_curses_dir=$withval],
1836 [cf_cv_curses_dir=no])
1837])dnl
1838dnl ---------------------------------------------------------------------------
1839dnl CF_XOPEN_CURSES version: 8 updated: 2003/11/07 19:47:46
1840dnl ---------------
1841dnl Test if we should define X/Open source for curses, needed on Digital Unix
1842dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
1843dnl
1844dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
1845dnl as getbegy(). The latter is better design, but the former is standard.
1846AC_DEFUN([CF_XOPEN_CURSES],
1847[
1848AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1849AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
1850AC_TRY_LINK([
1851#include <stdlib.h>
1852#include <${cf_cv_ncurses_header-curses.h}>],[
1853 long x = winnstr(stdscr, "", 0);
1854 int x1, y1;
1855 getbegyx(stdscr, y1, x1)],
1856 [cf_cv_need_xopen_extension=no],
1857 [AC_TRY_LINK([
1858#define _XOPEN_SOURCE_EXTENDED
1859#include <stdlib.h>
1860#include <${cf_cv_ncurses_header-curses.h}>],[
1861 long x = winnstr(stdscr, "", 0);
1862 int x1, y1;
1863 getbegyx(stdscr, y1, x1)],
1864 [cf_cv_need_xopen_extension=yes],
1865 [cf_cv_need_xopen_extension=unknown])])])
1866test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
1867])dnl
1868dnl ---------------------------------------------------------------------------
1869dnl CF_XOPEN_SOURCE version: 25 updated: 2007/01/29 18:36:38
1870dnl ---------------
1871dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1872dnl or adapt to the vendor's definitions to get equivalent functionality,
1873dnl without losing the common non-POSIX features.
1874dnl
1875dnl Parameters:
1876dnl $1 is the nominal value for _XOPEN_SOURCE
1877dnl $2 is the nominal value for _POSIX_C_SOURCE
1878AC_DEFUN([CF_XOPEN_SOURCE],[
1879
1880AC_REQUIRE([CF_PROG_CC_U_D])
1881
1882cf_XOPEN_SOURCE=ifelse($1,,500,$1)
1883cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
1884
1885case $host_os in #(vi
1886aix[[45]]*) #(vi
1887 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
1888 ;;
1889freebsd*) #(vi
1890 # 5.x headers associate
1891 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1892 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1893 cf_POSIX_C_SOURCE=200112L
1894 cf_XOPEN_SOURCE=600
1895 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1896 ;;
1897hpux*) #(vi
1898 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
1899 ;;
1900irix[[56]].*) #(vi
1901 CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
1902 ;;
1903linux*|gnu*|k*bsd*-gnu) #(vi
1904 CF_GNU_SOURCE
1905 ;;
1906mirbsd*) #(vi
1907 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
1908 ;;
1909netbsd*) #(vi
1910 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1911 ;;
1912openbsd*) #(vi
1913 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1914 ;;
1915osf[[45]]*) #(vi
1916 CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
1917 ;;
1918nto-qnx*) #(vi
1919 CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
1920 ;;
1921sco*) #(vi
1922 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1923 ;;
1924solaris*) #(vi
1925 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1926 ;;
1927*)
1928 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1929 AC_TRY_COMPILE([#include <sys/types.h>],[
1930#ifndef _XOPEN_SOURCE
1931make an error
1932#endif],
1933 [cf_cv_xopen_source=no],
1934 [cf_save="$CPPFLAGS"
1935 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1936 AC_TRY_COMPILE([#include <sys/types.h>],[
1937#ifdef _XOPEN_SOURCE
1938make an error
1939#endif],
1940 [cf_cv_xopen_source=no],
1941 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1942 CPPFLAGS="$cf_save"
1943 ])
1944])
1945 if test "$cf_cv_xopen_source" != no ; then
1946 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1947 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1948 test "$cf_cv_cc_u_d_options" = yes && \
1949 CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
1950 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
1951 fi
1952 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1953 ;;
1954esac
1955])
1956dnl ---------------------------------------------------------------------------
1957dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41
1958dnl -----------
1959dnl Check for Xaw (Athena) libraries
1960dnl
1961dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
1962AC_DEFUN([CF_X_ATHENA],
1963[AC_REQUIRE([CF_X_TOOLKIT])
1964cf_x_athena=${cf_x_athena-Xaw}
1965
1966AC_MSG_CHECKING(if you want to link with Xaw 3d library)
1967withval=
1968AC_ARG_WITH(Xaw3d,
1969 [ --with-Xaw3d link with Xaw 3d library])
1970if test "$withval" = yes ; then
1971 cf_x_athena=Xaw3d
1972 AC_MSG_RESULT(yes)
1973else
1974 AC_MSG_RESULT(no)
1975fi
1976
1977AC_MSG_CHECKING(if you want to link with neXT Athena library)
1978withval=
1979AC_ARG_WITH(neXtaw,
1980 [ --with-neXtaw link with neXT Athena library])
1981if test "$withval" = yes ; then
1982 cf_x_athena=neXtaw
1983 AC_MSG_RESULT(yes)
1984else
1985 AC_MSG_RESULT(no)
1986fi
1987
1988AC_MSG_CHECKING(if you want to link with Athena-Plus library)
1989withval=
1990AC_ARG_WITH(XawPlus,
1991 [ --with-XawPlus link with Athena-Plus library])
1992if test "$withval" = yes ; then
1993 cf_x_athena=XawPlus
1994 AC_MSG_RESULT(yes)
1995else
1996 AC_MSG_RESULT(no)
1997fi
1998
1999AC_CHECK_LIB(Xext,XextCreateExtension,
2000 [LIBS="-lXext $LIBS"])
2001
2002cf_x_athena_lib=""
2003
2004CF_X_ATHENA_CPPFLAGS($cf_x_athena)
2005CF_X_ATHENA_LIBS($cf_x_athena)
2006])dnl
2007dnl ---------------------------------------------------------------------------
2008dnl CF_X_ATHENA_CPPFLAGS version: 2 updated: 2002/10/09 20:00:37
2009dnl --------------------
2010dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2011dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2012AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
2013[
2014cf_x_athena_root=ifelse($1,,Xaw,$1)
2015cf_x_athena_include=""
2016
2017for cf_path in default \
2018 /usr/contrib/X11R6 \
2019 /usr/contrib/X11R5 \
2020 /usr/lib/X11R5 \
2021 /usr/local
2022do
2023 if test -z "$cf_x_athena_include" ; then
2024 cf_save="$CPPFLAGS"
2025 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
2026 if test $cf_path != default ; then
2027 CPPFLAGS="-I$cf_path/include $cf_save"
2028 AC_MSG_CHECKING(for $cf_test in $cf_path)
2029 else
2030 AC_MSG_CHECKING(for $cf_test)
2031 fi
2032 AC_TRY_COMPILE([
2033#include <X11/Intrinsic.h>
2034#include <$cf_test>],[],
2035 [cf_result=yes],
2036 [cf_result=no])
2037 AC_MSG_RESULT($cf_result)
2038 if test "$cf_result" = yes ; then
2039 cf_x_athena_include=$cf_path
2040 break
2041 else
2042 CPPFLAGS="$cf_save"
2043 fi
2044 fi
2045done
2046
2047if test -z "$cf_x_athena_include" ; then
2048 AC_MSG_WARN(
2049[Unable to successfully find Athena header files with test program])
2050elif test "$cf_x_athena_include" != default ; then
2051 CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include"
2052fi
2053])
2054dnl ---------------------------------------------------------------------------
2055dnl CF_X_ATHENA_LIBS version: 6 updated: 2006/11/30 17:57:11
2056dnl ----------------
2057dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2058dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2059AC_DEFUN([CF_X_ATHENA_LIBS],
2060[AC_REQUIRE([CF_X_TOOLKIT])
2061cf_x_athena_root=ifelse($1,,Xaw,$1)
2062cf_x_athena_lib=""
2063
2064for cf_path in default \
2065 /usr/contrib/X11R6 \
2066 /usr/contrib/X11R5 \
2067 /usr/lib/X11R5 \
2068 /usr/local
2069do
2070 for cf_lib in \
2071 "-l$cf_x_athena_root -lXmu" \
2072 "-l$cf_x_athena_root -lXpm -lXmu" \
2073 "-l${cf_x_athena_root}_s -lXmu_s"
2074 do
2075 if test -z "$cf_x_athena_lib" ; then
2076 cf_save="$LIBS"
2077 cf_test=XawSimpleMenuAddGlobalActions
2078 if test $cf_path != default ; then
2079 LIBS="-L$cf_path/lib $cf_lib $LIBS"
2080 AC_MSG_CHECKING(for $cf_lib in $cf_path)
2081 else
2082 LIBS="$cf_lib $LIBS"
2083 AC_MSG_CHECKING(for $cf_test in $cf_lib)
2084 fi
2085 AC_TRY_LINK([],[$cf_test()],
2086 [cf_result=yes],
2087 [cf_result=no])
2088 AC_MSG_RESULT($cf_result)
2089 if test "$cf_result" = yes ; then
2090 cf_x_athena_lib="$cf_lib"
2091 break
2092 fi
2093 LIBS="$cf_save"
2094 fi
2095 done
2096done
2097
2098if test -z "$cf_x_athena_lib" ; then
2099 AC_ERROR(
2100[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
2101fi
2102
2103CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2104AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2105])
2106dnl ---------------------------------------------------------------------------
2107dnl CF_X_TOOLKIT version: 11 updated: 2006/11/29 19:05:14
2108dnl ------------
2109dnl Check for X Toolkit libraries
2110dnl
2111AC_DEFUN([CF_X_TOOLKIT],
2112[
2113AC_REQUIRE([AC_PATH_XTRA])
2114AC_REQUIRE([CF_CHECK_CACHE])
2115
2116# SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
2117
2118cf_have_X_LIBS=no
2119
2120LDFLAGS="$X_LIBS $LDFLAGS"
2121CF_CHECK_CFLAGS($X_CFLAGS)
2122
2123AC_CHECK_FUNC(XOpenDisplay,,[
2124AC_CHECK_LIB(X11,XOpenDisplay,
2125 [LIBS="-lX11 $LIBS"],,
2126 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2127
2128AC_CHECK_FUNC(XtAppInitialize,,[
2129AC_CHECK_LIB(Xt, XtAppInitialize,
2130 [AC_DEFINE(HAVE_LIBXT)
2131 cf_have_X_LIBS=Xt
2132 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
2133 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2134
2135if test $cf_have_X_LIBS = no ; then
2136 AC_WARN(
2137[Unable to successfully link X Toolkit library (-lXt) with
2138test program. You will have to check and add the proper libraries by hand
2139to makefile.])
2140fi
2141])dnl