1 # terminfo.m4 serial 3 (gettext-0.18)
2 dnl Copyright (C) 2000-2002, 2006, 2008 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
9 AC_DEFUN([gl_TERMINFO],
11 AC_REQUIRE([gl_TERMINFO_BODY])
12 if test $gl_cv_terminfo_tparam = no && test $gl_cv_terminfo_tparm = no; then
15 case "$gl_cv_terminfo" in
17 case "$gl_cv_termcap" in
26 AC_DEFUN([gl_TERMINFO_BODY],
28 dnl Some systems have setupterm(), tigetnum(), tigetstr(), tigetflag(),
29 dnl tputs(), tgoto() in the same library as tgetent(), tgetnum(), tgetstr(),
30 dnl tgetflag(), e.g. Linux (in libncurses) or Solaris (in libtermcap =
32 dnl Some systems have them in a different library, e.g. OSF/1 (in libcurses,
33 dnl not in libtermcap) or HP-UX (in libxcurses, not in libtermcap).
34 dnl Some systems, like NetBSD or BeOS, don't have these functions at all;
35 dnl they have only a libtermcap.
36 dnl Some systems, like BeOS, use GNU termcap, which has tparam() instead of
38 dnl Some systems, like mingw, have nothing at all.
40 dnl Some people want to avoid these libraries, in special situations such
41 dnl as when cross-compiling.
42 AC_REQUIRE([gl_CURSES])
44 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
45 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
46 AC_REQUIRE([AC_LIB_RPATH])
48 if test "$gl_curses_allowed" != no; then
50 dnl Search for libncurses and define LIBNCURSES, LTLIBNCURSES and INCNCURSES
52 AC_LIB_LINKFLAGS_BODY([ncurses])
54 dnl Search for libtermcap and define LIBTERMCAP, LTLIBTERMCAP and INCTERMCAP
56 AC_LIB_LINKFLAGS_BODY([termcap])
58 dnl Search for libxcurses and define LIBXCURSES, LTLIBXCURSES and INCXCURSES
60 AC_LIB_LINKFLAGS_BODY([xcurses])
62 dnl Search for libcurses and define LIBCURSES, LTLIBCURSES and INCCURSES
64 AC_LIB_LINKFLAGS_BODY([curses])
86 dnl When searching for the terminfo functions, prefer libtermcap over
87 dnl libxcurses and libcurses, because it is smaller.
88 AC_CACHE_CHECK([where terminfo library functions come from], [gl_cv_terminfo], [
89 gl_cv_terminfo="not found, consider installing GNU ncurses"
94 int setupterm (const char *, int, int *);
99 int tigetnum (const char *);
104 int tigetflag (const char *);
109 const char * tigetstr (const char *);
110 ], [return setupterm ("xterm", 0, (int *)0)
111 + tigetnum ("colors")
112 + tigetflag ("hc") + * tigetstr("oc");],
113 [gl_cv_terminfo=libc])
114 if test "$gl_cv_terminfo" != libc; then
116 LIBS="$LIBS $LIBNCURSES"
121 int setupterm (const char *, int, int *);
126 int tigetnum (const char *);
131 int tigetflag (const char *);
136 const char * tigetstr (const char *);
137 ], [return setupterm ("xterm", 0, (int *)0)
138 + tigetnum ("colors")
139 + tigetflag ("hc") + * tigetstr("oc");],
140 [gl_cv_terminfo=libncurses])
142 if test "$gl_cv_terminfo" != libncurses; then
144 LIBS="$LIBS $LIBTERMCAP"
149 int setupterm (const char *, int, int *);
154 int tigetnum (const char *);
159 int tigetflag (const char *);
164 const char * tigetstr (const char *);
165 ], [return setupterm ("xterm", 0, (int *)0)
166 + tigetnum ("colors")
167 + tigetflag ("hc") + * tigetstr("oc");],
168 [gl_cv_terminfo=libtermcap])
170 if test "$gl_cv_terminfo" != libtermcap; then
172 LIBS="$LIBS $LIBXCURSES"
177 int setupterm (const char *, int, int *);
182 int tigetnum (const char *);
187 int tigetflag (const char *);
192 const char * tigetstr (const char *);
193 ], [return setupterm ("xterm", 0, (int *)0)
194 + tigetnum ("colors")
195 + tigetflag ("hc") + * tigetstr("oc");],
196 [gl_cv_terminfo=libxcurses])
198 if test "$gl_cv_terminfo" != libxcurses; then
200 LIBS="$LIBS $LIBCURSES"
205 int setupterm (const char *, int, int *);
210 int tigetnum (const char *);
215 int tigetflag (const char *);
220 const char * tigetstr (const char *);
221 ], [return setupterm ("xterm", 0, (int *)0)
222 + tigetnum ("colors")
223 + tigetflag ("hc") + * tigetstr("oc");],
224 [gl_cv_terminfo=libcurses])
231 case "$gl_cv_terminfo" in
238 LIBTERMINFO="$LIBNCURSES"
239 LTLIBTERMINFO="$LTLIBNCURSES"
240 INCTERMINFO="$INCNCURSES"
243 LIBTERMINFO="$LIBTERMCAP"
244 LTLIBTERMINFO="$LTLIBTERMCAP"
245 INCTERMINFO="$INCTERMCAP"
248 LIBTERMINFO="$LIBXCURSES"
249 LTLIBTERMINFO="$LTLIBXCURSES"
250 INCTERMINFO="$INCXCURSES"
253 LIBTERMINFO="$LIBCURSES"
254 LTLIBTERMINFO="$LTLIBCURSES"
255 INCTERMINFO="$INCCURSES"
258 case "$gl_cv_terminfo" in
259 libc | libncurses | libtermcap | libxcurses | libcurses)
260 AC_DEFINE([HAVE_TERMINFO], 1,
261 [Define if setupterm(), tigetnum(), tigetstr(), tigetflag()
262 are among the termcap library functions.])
265 dnl Use the termcap functions as a fallback.
266 AC_CACHE_CHECK([where termcap library functions come from], [gl_cv_termcap], [
267 gl_cv_termcap="not found, consider installing GNU ncurses"
272 int tgetent (char *, const char *);
273 ], [return tgetent ((char *) 0, "xterm");],
274 [gl_cv_termcap=libc])
275 if test "$gl_cv_termcap" != libc; then
277 LIBS="$LIBS $LIBNCURSES"
282 int tgetent (char *, const char *);
283 ], [return tgetent ((char *) 0, "xterm");],
284 [gl_cv_termcap=libncurses])
286 if test "$gl_cv_termcap" != libncurses; then
288 LIBS="$LIBS $LIBTERMCAP"
293 int tgetent (char *, const char *);
294 ], [return tgetent ((char *) 0, "xterm");],
295 [gl_cv_termcap=libtermcap])
300 case "$gl_cv_termcap" in
307 LIBTERMINFO="$LIBNCURSES"
308 LTLIBTERMINFO="$LTLIBNCURSES"
309 INCTERMINFO="$INCNCURSES"
312 LIBTERMINFO="$LIBTERMCAP"
313 LTLIBTERMINFO="$LTLIBTERMCAP"
314 INCTERMINFO="$INCTERMCAP"
317 case "$gl_cv_termcap" in
318 libc | libncurses | libtermcap)
319 AC_DEFINE([HAVE_TERMCAP], 1,
320 [Define if tgetent(), tgetnum(), tgetstr(), tgetflag()
321 are among the termcap library functions.])
326 AC_SUBST([LIBTERMINFO])
327 AC_SUBST([LTLIBTERMINFO])
328 AC_SUBST([INCTERMINFO])
330 dnl Test against the old GNU termcap, which provides a tparam() function
331 dnl instead of the classical tparm() function.
332 AC_CACHE_CHECK([for tparam], [gl_cv_terminfo_tparam], [
334 LIBS="$LIBS $LIBTERMINFO"
335 gl_save_CPPFLAGS="$CPPFLAGS"
336 CPPFLAGS="$CPPFLAGS $INCTERMINFO"
341 char * tparam (const char *, void *, int, ...);
343 ], [return tparam ("\033\133%dm", &buf, 1, 8);],
344 [gl_cv_terminfo_tparam=yes], [gl_cv_terminfo_tparam=no])
345 CPPFLAGS="$gl_save_CPPFLAGS"
348 if test $gl_cv_terminfo_tparam = yes; then
349 AC_DEFINE([HAVE_TPARAM], 1,
350 [Define if tparam() is among the termcap library functions.])
352 dnl Test whether a tparm() function is provided. It is missing e.g.
353 dnl in NetBSD 3.0 libtermcap.
354 AC_CACHE_CHECK([for tparm], [gl_cv_terminfo_tparm], [
356 LIBS="$LIBS $LIBTERMINFO"
357 gl_save_CPPFLAGS="$CPPFLAGS"
358 CPPFLAGS="$CPPFLAGS $INCTERMINFO"
363 char * tparm (const char *, ...);
364 ], [return tparm ("\033\133%dm", 8);],
365 [gl_cv_terminfo_tparm=yes], [gl_cv_terminfo_tparm=no])
366 CPPFLAGS="$gl_save_CPPFLAGS"