1# terminfo.m4 serial 2 (gettext-0.17) 2dnl Copyright (C) 2000-2002, 2006 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_TERMINFO], 10[ 11 AC_REQUIRE([gl_TERMINFO_BODY]) 12 if test $gl_cv_terminfo_tparam = no && test $gl_cv_terminfo_tparm = no; then 13 AC_LIBOBJ([tparm]) 14 fi 15 case "$gl_cv_terminfo" in 16 no*) 17 case "$gl_cv_termcap" in 18 no*) 19 AC_LIBOBJ([tputs]) 20 ;; 21 esac 22 ;; 23 esac 24]) 25 26AC_DEFUN([gl_TERMINFO_BODY], 27[ 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 = 31 dnl libncurses). 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 37 dnl tparm(). 38 dnl Some systems, like mingw, have nothing at all. 39 40 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. 41 AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 42 AC_REQUIRE([AC_LIB_RPATH]) 43 44 dnl Search for libncurses and define LIBNCURSES, LTLIBNCURSES and INCNCURSES 45 dnl accordingly. 46 AC_LIB_LINKFLAGS_BODY([ncurses]) 47 48 dnl Search for libtermcap and define LIBTERMCAP, LTLIBTERMCAP and INCTERMCAP 49 dnl accordingly. 50 AC_LIB_LINKFLAGS_BODY([termcap]) 51 52 dnl Search for libxcurses and define LIBXCURSES, LTLIBXCURSES and INCXCURSES 53 dnl accordingly. 54 AC_LIB_LINKFLAGS_BODY([xcurses]) 55 56 dnl Search for libcurses and define LIBCURSES, LTLIBCURSES and INCCURSES 57 dnl accordingly. 58 AC_LIB_LINKFLAGS_BODY([curses]) 59 60 dnl When searching for the terminfo functions, prefer libtermcap over 61 dnl libxcurses and libcurses, because it is smaller. 62 AC_CACHE_CHECK([where terminfo library functions come from], [gl_cv_terminfo], [ 63 gl_cv_terminfo="not found, consider installing GNU ncurses" 64 AC_TRY_LINK([extern 65 #ifdef __cplusplus 66 "C" 67 #endif 68 int setupterm (const char *, int, int *); 69 extern 70 #ifdef __cplusplus 71 "C" 72 #endif 73 int tigetnum (const char *); 74 extern 75 #ifdef __cplusplus 76 "C" 77 #endif 78 int tigetflag (const char *); 79 extern 80 #ifdef __cplusplus 81 "C" 82 #endif 83 const char * tigetstr (const char *); 84 ], [return setupterm ("xterm", 0, (int *)0) 85 + tigetnum ("colors") 86 + tigetflag ("hc") + * tigetstr("oc");], 87 [gl_cv_terminfo=libc]) 88 if test "$gl_cv_terminfo" != libc; then 89 gl_save_LIBS="$LIBS" 90 LIBS="$LIBS $LIBNCURSES" 91 AC_TRY_LINK([extern 92 #ifdef __cplusplus 93 "C" 94 #endif 95 int setupterm (const char *, int, int *); 96 extern 97 #ifdef __cplusplus 98 "C" 99 #endif 100 int tigetnum (const char *); 101 extern 102 #ifdef __cplusplus 103 "C" 104 #endif 105 int tigetflag (const char *); 106 extern 107 #ifdef __cplusplus 108 "C" 109 #endif 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=libncurses]) 115 LIBS="$gl_save_LIBS" 116 if test "$gl_cv_terminfo" != libncurses; then 117 gl_save_LIBS="$LIBS" 118 LIBS="$LIBS $LIBTERMCAP" 119 AC_TRY_LINK([extern 120 #ifdef __cplusplus 121 "C" 122 #endif 123 int setupterm (const char *, int, int *); 124 extern 125 #ifdef __cplusplus 126 "C" 127 #endif 128 int tigetnum (const char *); 129 extern 130 #ifdef __cplusplus 131 "C" 132 #endif 133 int tigetflag (const char *); 134 extern 135 #ifdef __cplusplus 136 "C" 137 #endif 138 const char * tigetstr (const char *); 139 ], [return setupterm ("xterm", 0, (int *)0) 140 + tigetnum ("colors") 141 + tigetflag ("hc") + * tigetstr("oc");], 142 [gl_cv_terminfo=libtermcap]) 143 LIBS="$gl_save_LIBS" 144 if test "$gl_cv_terminfo" != libtermcap; then 145 gl_save_LIBS="$LIBS" 146 LIBS="$LIBS $LIBXCURSES" 147 AC_TRY_LINK([extern 148 #ifdef __cplusplus 149 "C" 150 #endif 151 int setupterm (const char *, int, int *); 152 extern 153 #ifdef __cplusplus 154 "C" 155 #endif 156 int tigetnum (const char *); 157 extern 158 #ifdef __cplusplus 159 "C" 160 #endif 161 int tigetflag (const char *); 162 extern 163 #ifdef __cplusplus 164 "C" 165 #endif 166 const char * tigetstr (const char *); 167 ], [return setupterm ("xterm", 0, (int *)0) 168 + tigetnum ("colors") 169 + tigetflag ("hc") + * tigetstr("oc");], 170 [gl_cv_terminfo=libxcurses]) 171 LIBS="$gl_save_LIBS" 172 if test "$gl_cv_terminfo" != libxcurses; then 173 gl_save_LIBS="$LIBS" 174 LIBS="$LIBS $LIBCURSES" 175 AC_TRY_LINK([extern 176 #ifdef __cplusplus 177 "C" 178 #endif 179 int setupterm (const char *, int, int *); 180 extern 181 #ifdef __cplusplus 182 "C" 183 #endif 184 int tigetnum (const char *); 185 extern 186 #ifdef __cplusplus 187 "C" 188 #endif 189 int tigetflag (const char *); 190 extern 191 #ifdef __cplusplus 192 "C" 193 #endif 194 const char * tigetstr (const char *); 195 ], [return setupterm ("xterm", 0, (int *)0) 196 + tigetnum ("colors") 197 + tigetflag ("hc") + * tigetstr("oc");], 198 [gl_cv_terminfo=libcurses]) 199 LIBS="$gl_save_LIBS" 200 fi 201 fi 202 fi 203 fi 204 ]) 205 case "$gl_cv_terminfo" in 206 libc) 207 LIBTERMINFO= 208 LTLIBTERMINFO= 209 INCTERMINFO= 210 ;; 211 libncurses) 212 LIBTERMINFO="$LIBNCURSES" 213 LTLIBTERMINFO="$LTLIBNCURSES" 214 INCTERMINFO="$INCNCURSES" 215 ;; 216 libtermcap) 217 LIBTERMINFO="$LIBTERMCAP" 218 LTLIBTERMINFO="$LTLIBTERMCAP" 219 INCTERMINFO="$INCTERMCAP" 220 ;; 221 libxcurses) 222 LIBTERMINFO="$LIBXCURSES" 223 LTLIBTERMINFO="$LTLIBXCURSES" 224 INCTERMINFO="$INCXCURSES" 225 ;; 226 libcurses) 227 LIBTERMINFO="$LIBCURSES" 228 LTLIBTERMINFO="$LTLIBCURSES" 229 INCTERMINFO="$INCCURSES" 230 ;; 231 esac 232 case "$gl_cv_terminfo" in 233 libc | libncurses | libtermcap | libxcurses | libcurses) 234 AC_DEFINE([HAVE_TERMINFO], 1, 235 [Define if setupterm(), tigetnum(), tigetstr(), tigetflag() 236 are among the termcap library functions.]) 237 ;; 238 *) 239 dnl Use the termcap functions as a fallback. 240 AC_CACHE_CHECK([where termcap library functions come from], [gl_cv_termcap], [ 241 gl_cv_termcap="not found, consider installing GNU ncurses" 242 AC_TRY_LINK([extern 243 #ifdef __cplusplus 244 "C" 245 #endif 246 int tgetent (char *, const char *); 247 ], [return tgetent ((char *) 0, "xterm");], 248 [gl_cv_termcap=libc]) 249 if test "$gl_cv_termcap" != libc; then 250 gl_save_LIBS="$LIBS" 251 LIBS="$LIBS $LIBNCURSES" 252 AC_TRY_LINK([extern 253 #ifdef __cplusplus 254 "C" 255 #endif 256 int tgetent (char *, const char *); 257 ], [return tgetent ((char *) 0, "xterm");], 258 [gl_cv_termcap=libncurses]) 259 LIBS="$gl_save_LIBS" 260 if test "$gl_cv_termcap" != libncurses; then 261 gl_save_LIBS="$LIBS" 262 LIBS="$LIBS $LIBTERMCAP" 263 AC_TRY_LINK([extern 264 #ifdef __cplusplus 265 "C" 266 #endif 267 int tgetent (char *, const char *); 268 ], [return tgetent ((char *) 0, "xterm");], 269 [gl_cv_termcap=libtermcap]) 270 LIBS="$gl_save_LIBS" 271 fi 272 fi 273 ]) 274 case "$gl_cv_termcap" in 275 libc) 276 LIBTERMINFO= 277 LTLIBTERMINFO= 278 INCTERMINFO= 279 ;; 280 libncurses) 281 LIBTERMINFO="$LIBNCURSES" 282 LTLIBTERMINFO="$LTLIBNCURSES" 283 INCTERMINFO="$INCNCURSES" 284 ;; 285 libtermcap) 286 LIBTERMINFO="$LIBTERMCAP" 287 LTLIBTERMINFO="$LTLIBTERMCAP" 288 INCTERMINFO="$INCTERMCAP" 289 ;; 290 esac 291 case "$gl_cv_termcap" in 292 libc | libncurses | libtermcap) 293 AC_DEFINE([HAVE_TERMCAP], 1, 294 [Define if tgetent(), tgetnum(), tgetstr(), tgetflag() 295 are among the termcap library functions.]) 296 ;; 297 esac 298 ;; 299 esac 300 AC_SUBST([LIBTERMINFO]) 301 AC_SUBST([LTLIBTERMINFO]) 302 AC_SUBST([INCTERMINFO]) 303 304 dnl Test against the old GNU termcap, which provides a tparam() function 305 dnl instead of the classical tparm() function. 306 AC_CACHE_CHECK([for tparam], [gl_cv_terminfo_tparam], [ 307 gl_save_LIBS="$LIBS" 308 LIBS="$LIBS $LIBTERMINFO" 309 gl_save_CPPFLAGS="$CPPFLAGS" 310 CPPFLAGS="$CPPFLAGS $INCTERMINFO" 311 AC_TRY_LINK([extern 312 #ifdef __cplusplus 313 "C" 314 #endif 315 char * tparam (const char *, void *, int, ...); 316 char buf; 317 ], [return tparam ("\033\133%dm", &buf, 1, 8);], 318 [gl_cv_terminfo_tparam=yes], [gl_cv_terminfo_tparam=no]) 319 CPPFLAGS="$gl_save_CPPFLAGS" 320 LIBS="$gl_save_LIBS" 321 ]) 322 if test $gl_cv_terminfo_tparam = yes; then 323 AC_DEFINE([HAVE_TPARAM], 1, 324 [Define if tparam() is among the termcap library functions.]) 325 else 326 dnl Test whether a tparm() function is provided. It is missing e.g. 327 dnl in NetBSD 3.0 libtermcap. 328 AC_CACHE_CHECK([for tparm], [gl_cv_terminfo_tparm], [ 329 gl_save_LIBS="$LIBS" 330 LIBS="$LIBS $LIBTERMINFO" 331 gl_save_CPPFLAGS="$CPPFLAGS" 332 CPPFLAGS="$CPPFLAGS $INCTERMINFO" 333 AC_TRY_LINK([extern 334 #ifdef __cplusplus 335 "C" 336 #endif 337 char * tparm (const char *, ...); 338 ], [return tparm ("\033\133%dm", 8);], 339 [gl_cv_terminfo_tparm=yes], [gl_cv_terminfo_tparm=no]) 340 CPPFLAGS="$gl_save_CPPFLAGS" 341 LIBS="$gl_save_LIBS" 342 ]) 343 fi 344]) 345