]> git.deb.at Git - pkg/abook.git/blob - acinclude.m4
Revert "Add fix_spelling_error_in_binary.diff patch"
[pkg/abook.git] / acinclude.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Look for the curses libraries.  Older curses implementations may require
3 dnl termcap/termlib to be linked as well.
4 AC_DEFUN([CF_CURSES_LIBS],[
5 AC_CHECK_FUNC(initscr,,[
6 case $host_os in #(vi
7 freebsd*) #(vi
8         AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
9         ;;
10 hpux10.*|hpux11.*)
11         AC_CHECK_LIB(cur_colr,initscr,[
12                 LIBS="-lcur_colr $LIBS"
13                 CFLAGS="-I/usr/include/curses_colr $CFLAGS"
14                 ac_cv_func_initscr=yes
15                 ],[
16         AC_CHECK_LIB(Hcurses,initscr,[
17                 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
18                 LIBS="-lHcurses $LIBS"
19                 CFLAGS="-D__HP_CURSES -D_HP_CURSES $CFLAGS"
20                 ac_cv_func_initscr=yes
21                 ])])
22         ;;
23 linux*) # Suse Linux does not follow /usr/lib convention
24         LIBS="$LIBS -L/lib"
25         ;;
26 esac
27
28 if test ".$With5lib" != ".no" ; then
29 if test -d /usr/5lib ; then
30         # SunOS 3.x or 4.x
31         CPPFLAGS="$CPPFLAGS -I/usr/5include"
32         LIBS="$LIBS -L/usr/5lib"
33 fi
34 fi
35
36 if test ".$ac_cv_func_initscr" != .yes ; then
37         cf_save_LIBS="$LIBS"
38         cf_term_lib=""
39         cf_curs_lib=""
40
41         # Check for library containing tgoto.  Do this before curses library
42         # because it may be needed to link the test-case for initscr.
43         AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
44                 for cf_term_lib in termcap termlib unknown
45                 do
46                         AC_CHECK_LIB($cf_term_lib,tgoto,[break])
47                 done
48         ])
49
50         # Check for library containing initscr
51         test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
52         for cf_curs_lib in cursesX curses ncurses xcurses jcurses unknown
53         do
54                 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
55         done
56         test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
57
58         LIBS="-l$cf_curs_lib $cf_save_LIBS"
59         if test "$cf_term_lib" = unknown ; then
60                 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
61                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
62                         [initscr()],
63                         [cf_result=yes],
64                         [cf_result=no])
65                 AC_MSG_RESULT($cf_result)
66                 test $cf_result = no && AC_ERROR(Cannot link curses library)
67         elif test "$cf_term_lib" != predefined ; then
68                 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
69                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
70                         [initscr(); tgoto((char *)0, 0, 0);],
71                         [cf_result=no],
72                         [
73                         LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
74                         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
75                                 [initscr()],
76                                 [cf_result=yes],
77                                 [cf_result=error])
78                         ])
79                 AC_MSG_RESULT($cf_result)
80         fi
81 fi
82
83 ])])
84
85
86
87 dnl @synopsis AC_LIB_READLINE
88 dnl
89 dnl Searches for a readline compatible library.  If found, defines
90 dnl `HAVE_LIBREADLINE'.  If the found library has the `add_history'
91 dnl function, sets also `HAVE_READLINE_HISTORY'.  Also checks for the
92 dnl locations of the necessary include files and sets `HAVE_READLINE_H'
93 dnl or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
94 dnl 'HAVE_HISTORY_H' if the corresponding include files exists.
95 dnl
96 dnl The libraries that may be readline compatible are `libedit',
97 dnl `libeditline' and `libreadline'.  Sometimes we need to link a termcap
98 dnl library for readline to work, this macro tests these cases too by
99 dnl trying to link with `libtermcap', `libcurses' or `libncurses' before
100 dnl giving up.
101 dnl
102 dnl Here is an example of how to use the information provided by this
103 dnl macro to perform the necessary includes or declarations in a C file:
104 dnl
105 dnl   #include <config.h>
106 dnl
107 dnl   #ifdef HAVE_LIBREADLINE
108 dnl   #if defined(HAVE_READLINE_READLINE_H)
109 dnl   #include <readline/readline.h>
110 dnl   #elif defined(HAVE_READLINE_H)
111 dnl   #include <readline.h>
112 dnl   #else /* !defined(HAVE_READLINE_H) */
113 dnl   extern char *readline ();
114 dnl   #endif /* !defined(HAVE_READLINE_H) */
115 dnl   char *cmdline = NULL;
116 dnl   #else /* !defined(HAVE_READLINE_READLINE_H) */
117 dnl     /* no readline */
118 dnl   #endif /* HAVE_LIBREADLINE */
119 dnl
120 dnl   #ifdef HAVE_READLINE_HISTORY
121 dnl   #if defined(HAVE_READLINE_HISTORY_H)
122 dnl   #include <readline/history.h>
123 dnl   #elif defined(HAVE_HISTORY_H)
124 dnl   #include <history.h>
125 dnl   #else /* !defined(HAVE_HISTORY_H) */
126 dnl   extern void add_history ();
127 dnl   extern int write_history ();
128 dnl   extern int read_history ();
129 dnl   #endif /* defined(HAVE_READLINE_HISTORY_H) */
130 dnl     /* no history */
131 dnl   #endif /* HAVE_READLINE_HISTORY */
132 dnl
133 dnl
134 dnl @version $Id$
135 dnl @author Ville Laurikari <vl@iki.fi>
136 dnl
137 AC_DEFUN([AC_LIB_READLINE], [
138   AC_CACHE_CHECK([for a readline compatible library],
139                  ac_cv_lib_readline, [
140     ORIG_LIBS="$LIBS"
141     for readline_lib in readline edit editline; do
142       for termcap_lib in "" termcap curses ncurses; do
143         if test -z "$termcap_lib"; then
144           TRY_LIB="-l$readline_lib"
145         else
146           TRY_LIB="-l$readline_lib -l$termcap_lib"
147         fi
148         LIBS="$ORIG_LIBS $TRY_LIB"
149         AC_TRY_LINK_FUNC(readline, ac_cv_lib_readline="$TRY_LIB")
150         if test -n "$ac_cv_lib_readline"; then
151           break
152         fi
153       done
154       if test -n "$ac_cv_lib_readline"; then
155         break
156       fi
157     done
158     if test -z "$ac_cv_lib_readline"; then
159       ac_cv_lib_readline="no"
160     fi
161     LIBS="$ORIG_LIBS"
162   ])
163
164   if test "$ac_cv_lib_readline" != "no"; then
165     LIBS="$LIBS $ac_cv_lib_readline"
166     AC_DEFINE(HAVE_LIBREADLINE, 1,
167               [Define if you have a readline compatible library])
168     AC_CHECK_HEADERS(readline.h readline/readline.h)
169     AC_CACHE_CHECK([whether readline supports history],
170                    ac_cv_lib_readline_history, [
171       ac_cv_lib_readline_history="no"
172       AC_TRY_LINK_FUNC(add_history, ac_cv_lib_readline_history="yes")
173     ])
174     if test "$ac_cv_lib_readline_history" = "yes"; then
175       AC_DEFINE(HAVE_READLINE_HISTORY, 1,
176                 [Define if your readline library has \`add_history'])
177       AC_CHECK_HEADERS(history.h readline/history.h)
178     fi
179   fi
180
181 ])