]> git.deb.at Git - pkg/abook.git/blob - aclocal.m4
initial readline support
[pkg/abook.git] / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4-p5
2
3 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl ---------------------------------------------------------------------------
14 dnl Look for the curses libraries.  Older curses implementations may require
15 dnl termcap/termlib to be linked as well.
16 AC_DEFUN([CF_CURSES_LIBS],[
17 AC_CHECK_FUNC(initscr,,[
18 case $host_os in #(vi
19 freebsd*) #(vi
20         AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
21         ;;
22 hpux10.*|hpux11.*)
23         AC_CHECK_LIB(cur_colr,initscr,[
24                 LIBS="-lcur_colr $LIBS"
25                 CFLAGS="-I/usr/include/curses_colr $CFLAGS"
26                 ac_cv_func_initscr=yes
27                 ],[
28         AC_CHECK_LIB(Hcurses,initscr,[
29                 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
30                 LIBS="-lHcurses $LIBS"
31                 CFLAGS="-D__HP_CURSES -D_HP_CURSES $CFLAGS"
32                 ac_cv_func_initscr=yes
33                 ])])
34         ;;
35 linux*) # Suse Linux does not follow /usr/lib convention
36         LIBS="$LIBS -L/lib"
37         ;;
38 esac
39
40 if test ".$With5lib" != ".no" ; then
41 if test -d /usr/5lib ; then
42         # SunOS 3.x or 4.x
43         CPPFLAGS="$CPPFLAGS -I/usr/5include"
44         LIBS="$LIBS -L/usr/5lib"
45 fi
46 fi
47
48 if test ".$ac_cv_func_initscr" != .yes ; then
49         cf_save_LIBS="$LIBS"
50         cf_term_lib=""
51         cf_curs_lib=""
52
53         # Check for library containing tgoto.  Do this before curses library
54         # because it may be needed to link the test-case for initscr.
55         AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
56                 for cf_term_lib in termcap termlib unknown
57                 do
58                         AC_CHECK_LIB($cf_term_lib,tgoto,[break])
59                 done
60         ])
61
62         # Check for library containing initscr
63         test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
64         for cf_curs_lib in cursesX curses ncurses xcurses jcurses unknown
65         do
66                 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
67         done
68         test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
69
70         LIBS="-l$cf_curs_lib $cf_save_LIBS"
71         if test "$cf_term_lib" = unknown ; then
72                 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
73                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
74                         [initscr()],
75                         [cf_result=yes],
76                         [cf_result=no])
77                 AC_MSG_RESULT($cf_result)
78                 test $cf_result = no && AC_ERROR(Cannot link curses library)
79         elif test "$cf_term_lib" != predefined ; then
80                 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
81                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
82                         [initscr(); tgoto((char *)0, 0, 0);],
83                         [cf_result=no],
84                         [
85                         LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
86                         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
87                                 [initscr()],
88                                 [cf_result=yes],
89                                 [cf_result=error])
90                         ])
91                 AC_MSG_RESULT($cf_result)
92         fi
93 fi
94
95 ])])
96
97
98
99 dnl @synopsis AC_LIB_READLINE
100 dnl
101 dnl Searches for a readline compatible library.  If found, defines
102 dnl `HAVE_LIBREADLINE'.  If the found library has the `add_history'
103 dnl function, sets also `HAVE_READLINE_HISTORY'.  Also checks for the
104 dnl locations of the necessary include files and sets `HAVE_READLINE_H'
105 dnl or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
106 dnl 'HAVE_HISTORY_H' if the corresponding include files exists.
107 dnl
108 dnl The libraries that may be readline compatible are `libedit',
109 dnl `libeditline' and `libreadline'.  Sometimes we need to link a termcap
110 dnl library for readline to work, this macro tests these cases too by
111 dnl trying to link with `libtermcap', `libcurses' or `libncurses' before
112 dnl giving up.
113 dnl
114 dnl Here is an example of how to use the information provided by this
115 dnl macro to perform the necessary includes or declarations in a C file:
116 dnl
117 dnl   #include <config.h>
118 dnl
119 dnl   #ifdef HAVE_LIBREADLINE
120 dnl   #if defined(HAVE_READLINE_READLINE_H)
121 dnl   #include <readline/readline.h>
122 dnl   #elif defined(HAVE_READLINE_H)
123 dnl   #include <readline.h>
124 dnl   #else /* !defined(HAVE_READLINE_H) */
125 dnl   extern char *readline ();
126 dnl   #endif /* !defined(HAVE_READLINE_H) */
127 dnl   char *cmdline = NULL;
128 dnl   #else /* !defined(HAVE_READLINE_READLINE_H) */
129 dnl     /* no readline */
130 dnl   #endif /* HAVE_LIBREADLINE */
131 dnl
132 dnl   #ifdef HAVE_READLINE_HISTORY
133 dnl   #if defined(HAVE_READLINE_HISTORY_H)
134 dnl   #include <readline/history.h>
135 dnl   #elif defined(HAVE_HISTORY_H)
136 dnl   #include <history.h>
137 dnl   #else /* !defined(HAVE_HISTORY_H) */
138 dnl   extern void add_history ();
139 dnl   extern int write_history ();
140 dnl   extern int read_history ();
141 dnl   #endif /* defined(HAVE_READLINE_HISTORY_H) */
142 dnl     /* no history */
143 dnl   #endif /* HAVE_READLINE_HISTORY */
144 dnl
145 dnl
146 dnl @version $Id$
147 dnl @author Ville Laurikari <vl@iki.fi>
148 dnl
149 AC_DEFUN([AC_LIB_READLINE], [
150   AC_CACHE_CHECK([for a readline compatible library],
151                  ac_cv_lib_readline, [
152     ORIG_LIBS=$LIBS
153     for readline_lib in readline edit editline; do
154       for termcap_lib in "" termcap curses ncurses; do
155         if test -z "$termcap_lib"; then
156           TRY_LIB="-l$readline_lib"
157         else
158           TRY_LIB="-l$readline_lib -l$termcap_lib"
159         fi
160         LIBS="$ORIG_LIBS $TRY_LIB"
161         AC_TRY_LINK_FUNC(readline, ac_cv_lib_readline="$TRY_LIB")
162         if test -n "$ac_cv_lib_readline"; then
163           break
164         fi
165       done
166       if test -n "$ac_cv_lib_readline"; then
167         break
168       fi
169     done
170     if test -z "$ac_cv_lib_readline"; then
171       ac_cv_lib_readline="no"
172       LIBS=$ORIG_LIBS
173     fi
174   ])
175
176   if test "$ac_cv_lib_readline" != "no"; then
177     AC_DEFINE(HAVE_LIBREADLINE, 1,
178               [Define if you have a readline compatible library])
179     AC_CHECK_HEADERS(readline.h readline/readline.h)
180     AC_CACHE_CHECK([whether readline supports history],
181                    ac_cv_lib_readline_history, [
182       ac_cv_lib_readline_history="no"
183       AC_TRY_LINK_FUNC(add_history, ac_cv_lib_readline_history="yes")
184     ])
185     if test "$ac_cv_lib_readline_history" = "yes"; then
186       AC_DEFINE(HAVE_READLINE_HISTORY, 1,
187                 [Define if your readline library has \`add_history'])
188       AC_CHECK_HEADERS(history.h readline/history.h)
189     fi
190   fi
191 ])
192
193 # Do all the work for Automake.  This macro actually does too much --
194 # some checks are only needed if your package does certain things.
195 # But this isn't really a big deal.
196
197 # serial 1
198
199 dnl Usage:
200 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
201
202 AC_DEFUN([AM_INIT_AUTOMAKE],
203 [AC_REQUIRE([AC_PROG_INSTALL])
204 PACKAGE=[$1]
205 AC_SUBST(PACKAGE)
206 VERSION=[$2]
207 AC_SUBST(VERSION)
208 dnl test to see if srcdir already configured
209 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
210   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
211 fi
212 ifelse([$3],,
213 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
214 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
215 AC_REQUIRE([AM_SANITY_CHECK])
216 AC_REQUIRE([AC_ARG_PROGRAM])
217 dnl FIXME This is truly gross.
218 missing_dir=`cd $ac_aux_dir && pwd`
219 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
220 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
221 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
222 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
223 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
224 AC_REQUIRE([AC_PROG_MAKE_SET])])
225
226 #
227 # Check to make sure that the build environment is sane.
228 #
229
230 AC_DEFUN([AM_SANITY_CHECK],
231 [AC_MSG_CHECKING([whether build environment is sane])
232 # Just in case
233 sleep 1
234 echo timestamp > conftestfile
235 # Do `set' in a subshell so we don't clobber the current shell's
236 # arguments.  Must try -L first in case configure is actually a
237 # symlink; some systems play weird games with the mod time of symlinks
238 # (eg FreeBSD returns the mod time of the symlink's containing
239 # directory).
240 if (
241    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
242    if test "[$]*" = "X"; then
243       # -L didn't work.
244       set X `ls -t $srcdir/configure conftestfile`
245    fi
246    if test "[$]*" != "X $srcdir/configure conftestfile" \
247       && test "[$]*" != "X conftestfile $srcdir/configure"; then
248
249       # If neither matched, then we have a broken ls.  This can happen
250       # if, for instance, CONFIG_SHELL is bash and it inherits a
251       # broken ls alias from the environment.  This has actually
252       # happened.  Such a system could not be considered "sane".
253       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
254 alias in your environment])
255    fi
256
257    test "[$]2" = conftestfile
258    )
259 then
260    # Ok.
261    :
262 else
263    AC_MSG_ERROR([newly created file is older than distributed files!
264 Check your system clock])
265 fi
266 rm -f conftest*
267 AC_MSG_RESULT(yes)])
268
269 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
270 dnl The program must properly implement --version.
271 AC_DEFUN([AM_MISSING_PROG],
272 [AC_MSG_CHECKING(for working $2)
273 # Run test in a subshell; some versions of sh will print an error if
274 # an executable is not found, even if stderr is redirected.
275 # Redirect stdin to placate older versions of autoconf.  Sigh.
276 if ($2 --version) < /dev/null > /dev/null 2>&1; then
277    $1=$2
278    AC_MSG_RESULT(found)
279 else
280    $1="$3/missing $2"
281    AC_MSG_RESULT(missing)
282 fi
283 AC_SUBST($1)])
284
285 # Like AC_CONFIG_HEADER, but automatically create stamp file.
286
287 AC_DEFUN([AM_CONFIG_HEADER],
288 [AC_PREREQ([2.12])
289 AC_CONFIG_HEADER([$1])
290 dnl When config.status generates a header, we must update the stamp-h file.
291 dnl This file resides in the same directory as the config header
292 dnl that is generated.  We must strip everything past the first ":",
293 dnl and everything past the last "/".
294 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
295 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
296 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
297 <<am_indx=1
298 for am_file in <<$1>>; do
299   case " <<$>>CONFIG_HEADERS " in
300   *" <<$>>am_file "*<<)>>
301     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
302     ;;
303   esac
304   am_indx=`expr "<<$>>am_indx" + 1`
305 done<<>>dnl>>)
306 changequote([,]))])
307
308 #serial 1
309 # This test replaces the one in autoconf.
310 # Currently this macro should have the same name as the autoconf macro
311 # because gettext's gettext.m4 (distributed in the automake package)
312 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
313 # give these diagnostics:
314 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
315 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
316
317 undefine([AC_ISC_POSIX])
318
319 AC_DEFUN([AC_ISC_POSIX],
320   [
321     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
322     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
323   ]
324 )
325
326
327 # serial 1
328
329 AC_DEFUN([AM_C_PROTOTYPES],
330 [AC_REQUIRE([AM_PROG_CC_STDC])
331 AC_REQUIRE([AC_PROG_CPP])
332 AC_MSG_CHECKING([for function prototypes])
333 if test "$am_cv_prog_cc_stdc" != no; then
334   AC_MSG_RESULT(yes)
335   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
336   U= ANSI2KNR=
337 else
338   AC_MSG_RESULT(no)
339   U=_ ANSI2KNR=./ansi2knr
340   # Ensure some checks needed by ansi2knr itself.
341   AC_HEADER_STDC
342   AC_CHECK_HEADERS(string.h)
343 fi
344 AC_SUBST(U)dnl
345 AC_SUBST(ANSI2KNR)dnl
346 ])
347
348
349 # serial 1
350
351 # @defmac AC_PROG_CC_STDC
352 # @maindex PROG_CC_STDC
353 # @ovindex CC
354 # If the C compiler in not in ANSI C mode by default, try to add an option
355 # to output variable @code{CC} to make it so.  This macro tries various
356 # options that select ANSI C on some system or another.  It considers the
357 # compiler to be in ANSI C mode if it handles function prototypes correctly.
358 #
359 # If you use this macro, you should check after calling it whether the C
360 # compiler has been set to accept ANSI C; if not, the shell variable
361 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
362 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
363 # program @code{ansi2knr}, which comes with Ghostscript.
364 # @end defmac
365
366 AC_DEFUN([AM_PROG_CC_STDC],
367 [AC_REQUIRE([AC_PROG_CC])
368 AC_BEFORE([$0], [AC_C_INLINE])
369 AC_BEFORE([$0], [AC_C_CONST])
370 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
371 dnl a magic option to avoid problems with ANSI preprocessor commands
372 dnl like #elif.
373 dnl FIXME: can't do this because then AC_AIX won't work due to a
374 dnl circular dependency.
375 dnl AC_BEFORE([$0], [AC_PROG_CPP])
376 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
377 AC_CACHE_VAL(am_cv_prog_cc_stdc,
378 [am_cv_prog_cc_stdc=no
379 ac_save_CC="$CC"
380 # Don't try gcc -ansi; that turns off useful extensions and
381 # breaks some systems' header files.
382 # AIX                   -qlanglvl=ansi
383 # Ultrix and OSF/1      -std1
384 # HP-UX                 -Aa -D_HPUX_SOURCE
385 # SVR4                  -Xc -D__EXTENSIONS__
386 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
387 do
388   CC="$ac_save_CC $ac_arg"
389   AC_TRY_COMPILE(
390 [#include <stdarg.h>
391 #include <stdio.h>
392 #include <sys/types.h>
393 #include <sys/stat.h>
394 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
395 struct buf { int x; };
396 FILE * (*rcsopen) (struct buf *, struct stat *, int);
397 static char *e (p, i)
398      char **p;
399      int i;
400 {
401   return p[i];
402 }
403 static char *f (char * (*g) (char **, int), char **p, ...)
404 {
405   char *s;
406   va_list v;
407   va_start (v,p);
408   s = g (p, va_arg (v,int));
409   va_end (v);
410   return s;
411 }
412 int test (int i, double x);
413 struct s1 {int (*f) (int a);};
414 struct s2 {int (*f) (double a);};
415 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
416 int argc;
417 char **argv;
418 ], [
419 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
420 ],
421 [am_cv_prog_cc_stdc="$ac_arg"; break])
422 done
423 CC="$ac_save_CC"
424 ])
425 if test -z "$am_cv_prog_cc_stdc"; then
426   AC_MSG_RESULT([none needed])
427 else
428   AC_MSG_RESULT($am_cv_prog_cc_stdc)
429 fi
430 case "x$am_cv_prog_cc_stdc" in
431   x|xno) ;;
432   *) CC="$CC $am_cv_prog_cc_stdc" ;;
433 esac
434 ])
435