1 # termcap.m4 serial 7 (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_TERMCAP],
12 AC_REQUIRE([gl_TERMCAP_BODY])
13 if test $gl_cv_termcap_tparam = no && test $gl_cv_termcap_tparm = no; then
16 case "$gl_cv_termcap" in
23 AC_DEFUN([gl_TERMCAP_BODY],
25 dnl Some systems have tgetent(), tgetnum(), tgetstr(), tgetflag(), tparm(),
26 dnl tputs(), tgoto() in libc, some have it in libtermcap, some have it in
28 dnl When both libtermcap and libncurses exist, we prefer the latter,
29 dnl because libtermcap is unsecure by design and obsolete since 1994.
30 dnl libcurses is useless: all platforms which have libcurses also have
31 dnl libtermcap, and libcurses is unusable on some old Unices.
32 dnl Some systems have the terminfo functions setupterm(), tigetnum(),
33 dnl tigetstr(), tigetflag() in the same library.
34 dnl Some systems, like BeOS, use GNU termcap, which has tparam() instead of
36 dnl Some systems, like mingw, have nothing at all.
38 dnl Some people want to avoid these libraries, in special situations such
39 dnl as when cross-compiling.
40 AC_REQUIRE([gl_CURSES])
42 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
43 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
44 AC_REQUIRE([AC_LIB_RPATH])
46 if test "$gl_curses_allowed" != no; then
48 dnl Search for libncurses and define LIBNCURSES, LTLIBNCURSES and INCNCURSES
50 AC_LIB_LINKFLAGS_BODY([ncurses])
52 dnl Search for libtermcap and define LIBTERMCAP, LTLIBTERMCAP and INCTERMCAP
54 AC_LIB_LINKFLAGS_BODY([termcap])
68 AC_CACHE_CHECK([where termcap library functions come from], [gl_cv_termcap], [
69 gl_cv_termcap="not found, consider installing GNU ncurses"
74 int tgetent (char *, const char *);
75 ], [return tgetent ((char *) 0, "xterm");], [gl_cv_termcap=libc])
76 if test "$gl_cv_termcap" != libc; then
78 LIBS="$LIBS $LIBNCURSES"
83 int tgetent (char *, const char *);
84 ], [return tgetent ((char *) 0, "xterm");], [gl_cv_termcap=libncurses])
86 if test "$gl_cv_termcap" != libncurses; then
88 LIBS="$LIBS $LIBTERMCAP"
93 int tgetent (char *, const char *);
94 ], [return tgetent ((char *) 0, "xterm");], [gl_cv_termcap=libtermcap])
99 case "$gl_cv_termcap" in
106 LIBTERMCAP="$LIBNCURSES"
107 LTLIBTERMCAP="$LTLIBNCURSES"
108 INCTERMCAP="$INCNCURSES"
113 case "$gl_cv_termcap" in
114 libc | libncurses | libtermcap)
115 AC_DEFINE([HAVE_TERMCAP], 1,
116 [Define if tgetent(), tgetnum(), tgetstr(), tgetflag()
117 are among the termcap library functions.])
120 AC_SUBST([LIBTERMCAP])
121 AC_SUBST([LTLIBTERMCAP])
122 AC_SUBST([INCTERMCAP])
124 dnl Test whether the terminfo functions are available from the same library.
125 AC_CACHE_CHECK([for terminfo functions], [gl_cv_func_terminfo], [
127 LIBS="$LIBS $LIBTERMCAP"
128 gl_save_CPPFLAGS="$CPPFLAGS"
129 CPPFLAGS="$CPPFLAGS $INCTERMCAP"
134 int setupterm (const char *, int, int *);
139 int tigetnum (const char *);
144 int tigetflag (const char *);
149 const char * tigetstr (const char *);
150 ], [return setupterm ("xterm", 0, (int *)0)
151 + tigetnum ("colors") + tigetflag ("hc") + * tigetstr("oc");],
152 [gl_cv_func_terminfo=yes], [gl_cv_func_terminfo=no])
153 CPPFLAGS="$gl_save_CPPFLAGS"
156 if test $gl_cv_func_terminfo = yes; then
157 AC_DEFINE([HAVE_TERMINFO], 1,
158 [Define if setupterm(), tigetnum(), tigetstr(), tigetflag()
159 are among the termcap library functions.])
162 dnl Test against the old GNU termcap, which provides a tparam() function
163 dnl instead of the classical tparm() function.
164 AC_CACHE_CHECK([for tparam], [gl_cv_termcap_tparam], [
166 LIBS="$LIBS $LIBTERMCAP"
167 gl_save_CPPFLAGS="$CPPFLAGS"
168 CPPFLAGS="$CPPFLAGS $INCTERMCAP"
173 char * tparam (const char *, void *, int, ...);
175 ], [return tparam ("\033\133%dm", &buf, 1, 8);],
176 [gl_cv_termcap_tparam=yes], [gl_cv_termcap_tparam=no])
177 CPPFLAGS="$gl_save_CPPFLAGS"
180 if test $gl_cv_termcap_tparam = yes; then
181 AC_DEFINE([HAVE_TPARAM], 1,
182 [Define if tparam() is among the termcap library functions.])
184 dnl Test whether a tparm() function is provided. It is missing e.g.
185 dnl in NetBSD 3.0 libtermcap.
186 AC_CACHE_CHECK([for tparm], [gl_cv_termcap_tparm], [
188 LIBS="$LIBS $LIBTERMCAP"
189 gl_save_CPPFLAGS="$CPPFLAGS"
190 CPPFLAGS="$CPPFLAGS $INCTERMCAP"
195 char * tparm (const char *, ...);
196 ], [return tparm ("\033\133%dm", 8);],
197 [gl_cv_termcap_tparm=yes], [gl_cv_termcap_tparm=no])
198 CPPFLAGS="$gl_save_CPPFLAGS"