1 # terminfo.m4 serial 3 (gettext-0.18)
2 dnl Copyright (C) 2000-2002, 2006, 2008, 2015 Free Software Foundation,
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.
10 AC_DEFUN([gl_TERMINFO],
12 AC_REQUIRE([gl_TERMINFO_BODY])
13 if test $gl_cv_terminfo_tparam = no && test $gl_cv_terminfo_tparm = no; then
16 case "$gl_cv_terminfo" in
18 case "$gl_cv_termcap" in
27 AC_DEFUN([gl_TERMINFO_BODY],
29 dnl Some systems have setupterm(), tigetnum(), tigetstr(), tigetflag(),
30 dnl tputs(), tgoto() in the same library as tgetent(), tgetnum(), tgetstr(),
31 dnl tgetflag(), e.g. Linux (in libncurses) or Solaris (in libtermcap =
33 dnl Some systems have them in a different library, e.g. OSF/1 (in libcurses,
34 dnl not in libtermcap) or HP-UX (in libxcurses, not in libtermcap).
35 dnl Some systems, like NetBSD or BeOS, don't have these functions at all;
36 dnl they have only a libtermcap.
37 dnl Some systems, like BeOS, use GNU termcap, which has tparam() instead of
39 dnl Some systems, like mingw, have nothing at all.
41 dnl Some people want to avoid these libraries, in special situations such
42 dnl as when cross-compiling.
43 AC_REQUIRE([gl_CURSES])
45 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
46 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
47 AC_REQUIRE([AC_LIB_RPATH])
49 if test "$gl_curses_allowed" != no; then
51 dnl Search for libncurses and define LIBNCURSES, LTLIBNCURSES and INCNCURSES
53 AC_LIB_LINKFLAGS_BODY([ncurses])
55 dnl Search for libtermcap and define LIBTERMCAP, LTLIBTERMCAP and INCTERMCAP
57 AC_LIB_LINKFLAGS_BODY([termcap])
59 dnl Search for libxcurses and define LIBXCURSES, LTLIBXCURSES and INCXCURSES
61 AC_LIB_LINKFLAGS_BODY([xcurses])
63 dnl Search for libcurses and define LIBCURSES, LTLIBCURSES and INCCURSES
65 AC_LIB_LINKFLAGS_BODY([curses])
87 dnl When searching for the terminfo functions, prefer libtermcap over
88 dnl libxcurses and libcurses, because it is smaller.
89 AC_CACHE_CHECK([where terminfo library functions come from], [gl_cv_terminfo], [
90 gl_cv_terminfo="not found, consider installing GNU ncurses"
95 int setupterm (const char *, int, int *);
100 int tigetnum (const char *);
105 int tigetflag (const char *);
110 const char * tigetstr (const char *);
111 ], [return setupterm ("xterm", 0, (int *)0)
112 + tigetnum ("colors")
113 + tigetflag ("hc") + * tigetstr("oc");],
114 [gl_cv_terminfo=libc])
115 if test "$gl_cv_terminfo" != libc; then
117 LIBS="$LIBS $LIBNCURSES"
122 int setupterm (const char *, int, int *);
127 int tigetnum (const char *);
132 int tigetflag (const char *);
137 const char * tigetstr (const char *);
138 ], [return setupterm ("xterm", 0, (int *)0)
139 + tigetnum ("colors")
140 + tigetflag ("hc") + * tigetstr("oc");],
141 [gl_cv_terminfo=libncurses])
143 if test "$gl_cv_terminfo" != libncurses; then
145 LIBS="$LIBS $LIBTERMCAP"
150 int setupterm (const char *, int, int *);
155 int tigetnum (const char *);
160 int tigetflag (const char *);
165 const char * tigetstr (const char *);
166 ], [return setupterm ("xterm", 0, (int *)0)
167 + tigetnum ("colors")
168 + tigetflag ("hc") + * tigetstr("oc");],
169 [gl_cv_terminfo=libtermcap])
171 if test "$gl_cv_terminfo" != libtermcap; then
173 LIBS="$LIBS $LIBXCURSES"
178 int setupterm (const char *, int, int *);
183 int tigetnum (const char *);
188 int tigetflag (const char *);
193 const char * tigetstr (const char *);
194 ], [return setupterm ("xterm", 0, (int *)0)
195 + tigetnum ("colors")
196 + tigetflag ("hc") + * tigetstr("oc");],
197 [gl_cv_terminfo=libxcurses])
199 if test "$gl_cv_terminfo" != libxcurses; then
201 LIBS="$LIBS $LIBCURSES"
206 int setupterm (const char *, int, int *);
211 int tigetnum (const char *);
216 int tigetflag (const char *);
221 const char * tigetstr (const char *);
222 ], [return setupterm ("xterm", 0, (int *)0)
223 + tigetnum ("colors")
224 + tigetflag ("hc") + * tigetstr("oc");],
225 [gl_cv_terminfo=libcurses])
232 case "$gl_cv_terminfo" in
239 LIBTERMINFO="$LIBNCURSES"
240 LTLIBTERMINFO="$LTLIBNCURSES"
241 INCTERMINFO="$INCNCURSES"
244 LIBTERMINFO="$LIBTERMCAP"
245 LTLIBTERMINFO="$LTLIBTERMCAP"
246 INCTERMINFO="$INCTERMCAP"
249 LIBTERMINFO="$LIBXCURSES"
250 LTLIBTERMINFO="$LTLIBXCURSES"
251 INCTERMINFO="$INCXCURSES"
254 LIBTERMINFO="$LIBCURSES"
255 LTLIBTERMINFO="$LTLIBCURSES"
256 INCTERMINFO="$INCCURSES"
259 case "$gl_cv_terminfo" in
260 libc | libncurses | libtermcap | libxcurses | libcurses)
261 AC_DEFINE([HAVE_TERMINFO], 1,
262 [Define if setupterm(), tigetnum(), tigetstr(), tigetflag()
263 are among the termcap library functions.])
266 dnl Use the termcap functions as a fallback.
267 AC_CACHE_CHECK([where termcap library functions come from], [gl_cv_termcap], [
268 gl_cv_termcap="not found, consider installing GNU ncurses"
273 int tgetent (char *, const char *);
274 ], [return tgetent ((char *) 0, "xterm");],
275 [gl_cv_termcap=libc])
276 if test "$gl_cv_termcap" != libc; then
278 LIBS="$LIBS $LIBNCURSES"
283 int tgetent (char *, const char *);
284 ], [return tgetent ((char *) 0, "xterm");],
285 [gl_cv_termcap=libncurses])
287 if test "$gl_cv_termcap" != libncurses; then
289 LIBS="$LIBS $LIBTERMCAP"
294 int tgetent (char *, const char *);
295 ], [return tgetent ((char *) 0, "xterm");],
296 [gl_cv_termcap=libtermcap])
301 case "$gl_cv_termcap" in
308 LIBTERMINFO="$LIBNCURSES"
309 LTLIBTERMINFO="$LTLIBNCURSES"
310 INCTERMINFO="$INCNCURSES"
313 LIBTERMINFO="$LIBTERMCAP"
314 LTLIBTERMINFO="$LTLIBTERMCAP"
315 INCTERMINFO="$INCTERMCAP"
318 case "$gl_cv_termcap" in
319 libc | libncurses | libtermcap)
320 AC_DEFINE([HAVE_TERMCAP], 1,
321 [Define if tgetent(), tgetnum(), tgetstr(), tgetflag()
322 are among the termcap library functions.])
327 AC_SUBST([LIBTERMINFO])
328 AC_SUBST([LTLIBTERMINFO])
329 AC_SUBST([INCTERMINFO])
331 dnl Test against the old GNU termcap, which provides a tparam() function
332 dnl instead of the classical tparm() function.
333 AC_CACHE_CHECK([for tparam], [gl_cv_terminfo_tparam], [
335 LIBS="$LIBS $LIBTERMINFO"
336 gl_save_CPPFLAGS="$CPPFLAGS"
337 CPPFLAGS="$CPPFLAGS $INCTERMINFO"
342 char * tparam (const char *, void *, int, ...);
344 ], [return tparam ("\033\133%dm", &buf, 1, 8);],
345 [gl_cv_terminfo_tparam=yes], [gl_cv_terminfo_tparam=no])
346 CPPFLAGS="$gl_save_CPPFLAGS"
349 if test $gl_cv_terminfo_tparam = yes; then
350 AC_DEFINE([HAVE_TPARAM], 1,
351 [Define if tparam() is among the termcap library functions.])
353 dnl Test whether a tparm() function is provided. It is missing e.g.
354 dnl in NetBSD 3.0 libtermcap.
355 AC_CACHE_CHECK([for tparm], [gl_cv_terminfo_tparm], [
357 LIBS="$LIBS $LIBTERMINFO"
358 gl_save_CPPFLAGS="$CPPFLAGS"
359 CPPFLAGS="$CPPFLAGS $INCTERMINFO"
364 char * tparm (const char *, ...);
365 ], [return tparm ("\033\133%dm", 8);],
366 [gl_cv_terminfo_tparm=yes], [gl_cv_terminfo_tparm=no])
367 CPPFLAGS="$gl_save_CPPFLAGS"