1# termcap.m4 serial 7 (gettext-0.18) 2dnl Copyright (C) 2000-2002, 2006-2008 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl From Bruno Haible. 8 9AC_DEFUN([gl_TERMCAP], 10[ 11 AC_REQUIRE([gl_TERMCAP_BODY]) 12 if test $gl_cv_termcap_tparam = no && test $gl_cv_termcap_tparm = no; then 13 AC_LIBOBJ([tparm]) 14 fi 15 case "$gl_cv_termcap" in 16 no*) 17 AC_LIBOBJ([tputs]) 18 ;; 19 esac 20]) 21 22AC_DEFUN([gl_TERMCAP_BODY], 23[ 24 dnl Some systems have tgetent(), tgetnum(), tgetstr(), tgetflag(), tparm(), 25 dnl tputs(), tgoto() in libc, some have it in libtermcap, some have it in 26 dnl libncurses. 27 dnl When both libtermcap and libncurses exist, we prefer the latter, 28 dnl because libtermcap is unsecure by design and obsolete since 1994. 29 dnl libcurses is useless: all platforms which have libcurses also have 30 dnl libtermcap, and libcurses is unusable on some old Unices. 31 dnl Some systems have the terminfo functions setupterm(), tigetnum(), 32 dnl tigetstr(), tigetflag() in the same library. 33 dnl Some systems, like BeOS, use GNU termcap, which has tparam() instead of 34 dnl tparm(). 35 dnl Some systems, like mingw, have nothing at all. 36 37 dnl Some people want to avoid these libraries, in special situations such 38 dnl as when cross-compiling. 39 AC_REQUIRE([gl_CURSES]) 40 41 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. 42 AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 43 AC_REQUIRE([AC_LIB_RPATH]) 44 45 if test "$gl_curses_allowed" != no; then 46 47 dnl Search for libncurses and define LIBNCURSES, LTLIBNCURSES and INCNCURSES 48 dnl accordingly. 49 AC_LIB_LINKFLAGS_BODY([ncurses]) 50 51 dnl Search for libtermcap and define LIBTERMCAP, LTLIBTERMCAP and INCTERMCAP 52 dnl accordingly. 53 AC_LIB_LINKFLAGS_BODY([termcap]) 54 55 else 56 57 LIBNCURSES= 58 LTLIBNCURSES= 59 INCNCURSES= 60 61 LIBTERMCAP= 62 LTLIBTERMCAP= 63 INCTERMCAP= 64 65 fi 66 67 AC_CACHE_CHECK([where termcap library functions come from], [gl_cv_termcap], [ 68 gl_cv_termcap="not found, consider installing GNU ncurses" 69 AC_TRY_LINK([extern 70 #ifdef __cplusplus 71 "C" 72 #endif 73 int tgetent (char *, const char *); 74 ], [return tgetent ((char *) 0, "xterm");], [gl_cv_termcap=libc]) 75 if test "$gl_cv_termcap" != libc; then 76 gl_save_LIBS="$LIBS" 77 LIBS="$LIBS $LIBNCURSES" 78 AC_TRY_LINK([extern 79 #ifdef __cplusplus 80 "C" 81 #endif 82 int tgetent (char *, const char *); 83 ], [return tgetent ((char *) 0, "xterm");], [gl_cv_termcap=libncurses]) 84 LIBS="$gl_save_LIBS" 85 if test "$gl_cv_termcap" != libncurses; then 86 gl_save_LIBS="$LIBS" 87 LIBS="$LIBS $LIBTERMCAP" 88 AC_TRY_LINK([extern 89 #ifdef __cplusplus 90 "C" 91 #endif 92 int tgetent (char *, const char *); 93 ], [return tgetent ((char *) 0, "xterm");], [gl_cv_termcap=libtermcap]) 94 LIBS="$gl_save_LIBS" 95 fi 96 fi 97 ]) 98 case "$gl_cv_termcap" in 99 libc) 100 LIBTERMCAP= 101 LTLIBTERMCAP= 102 INCTERMCAP= 103 ;; 104 libncurses) 105 LIBTERMCAP="$LIBNCURSES" 106 LTLIBTERMCAP="$LTLIBNCURSES" 107 INCTERMCAP="$INCNCURSES" 108 ;; 109 libtermcap) 110 ;; 111 esac 112 case "$gl_cv_termcap" in 113 libc | libncurses | libtermcap) 114 AC_DEFINE([HAVE_TERMCAP], 1, 115 [Define if tgetent(), tgetnum(), tgetstr(), tgetflag() 116 are among the termcap library functions.]) 117 ;; 118 esac 119 AC_SUBST([LIBTERMCAP]) 120 AC_SUBST([LTLIBTERMCAP]) 121 AC_SUBST([INCTERMCAP]) 122 123 dnl Test whether the terminfo functions are available from the same library. 124 AC_CACHE_CHECK([for terminfo functions], [gl_cv_func_terminfo], [ 125 gl_save_LIBS="$LIBS" 126 LIBS="$LIBS $LIBTERMCAP" 127 gl_save_CPPFLAGS="$CPPFLAGS" 128 CPPFLAGS="$CPPFLAGS $INCTERMCAP" 129 AC_TRY_LINK([extern 130 #ifdef __cplusplus 131 "C" 132 #endif 133 int setupterm (const char *, int, int *); 134 extern 135 #ifdef __cplusplus 136 "C" 137 #endif 138 int tigetnum (const char *); 139 extern 140 #ifdef __cplusplus 141 "C" 142 #endif 143 int tigetflag (const char *); 144 extern 145 #ifdef __cplusplus 146 "C" 147 #endif 148 const char * tigetstr (const char *); 149 ], [return setupterm ("xterm", 0, (int *)0) 150 + tigetnum ("colors") + tigetflag ("hc") + * tigetstr("oc");], 151 [gl_cv_func_terminfo=yes], [gl_cv_func_terminfo=no]) 152 CPPFLAGS="$gl_save_CPPFLAGS" 153 LIBS="$gl_save_LIBS" 154 ]) 155 if test $gl_cv_func_terminfo = yes; then 156 AC_DEFINE([HAVE_TERMINFO], 1, 157 [Define if setupterm(), tigetnum(), tigetstr(), tigetflag() 158 are among the termcap library functions.]) 159 fi 160 161 dnl Test against the old GNU termcap, which provides a tparam() function 162 dnl instead of the classical tparm() function. 163 AC_CACHE_CHECK([for tparam], [gl_cv_termcap_tparam], [ 164 gl_save_LIBS="$LIBS" 165 LIBS="$LIBS $LIBTERMCAP" 166 gl_save_CPPFLAGS="$CPPFLAGS" 167 CPPFLAGS="$CPPFLAGS $INCTERMCAP" 168 AC_TRY_LINK([extern 169 #ifdef __cplusplus 170 "C" 171 #endif 172 char * tparam (const char *, void *, int, ...); 173 char buf; 174 ], [return tparam ("\033\133%dm", &buf, 1, 8);], 175 [gl_cv_termcap_tparam=yes], [gl_cv_termcap_tparam=no]) 176 CPPFLAGS="$gl_save_CPPFLAGS" 177 LIBS="$gl_save_LIBS" 178 ]) 179 if test $gl_cv_termcap_tparam = yes; then 180 AC_DEFINE([HAVE_TPARAM], 1, 181 [Define if tparam() is among the termcap library functions.]) 182 else 183 dnl Test whether a tparm() function is provided. It is missing e.g. 184 dnl in NetBSD 3.0 libtermcap. 185 AC_CACHE_CHECK([for tparm], [gl_cv_termcap_tparm], [ 186 gl_save_LIBS="$LIBS" 187 LIBS="$LIBS $LIBTERMCAP" 188 gl_save_CPPFLAGS="$CPPFLAGS" 189 CPPFLAGS="$CPPFLAGS $INCTERMCAP" 190 AC_TRY_LINK([extern 191 #ifdef __cplusplus 192 "C" 193 #endif 194 char * tparm (const char *, ...); 195 ], [return tparm ("\033\133%dm", 8);], 196 [gl_cv_termcap_tparm=yes], [gl_cv_termcap_tparm=no]) 197 CPPFLAGS="$gl_save_CPPFLAGS" 198 LIBS="$gl_save_LIBS" 199 ]) 200 fi 201]) 202