mc-with-screen-ncurses.m4 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. dnl check for ncurses in user supplied path
  2. AC_DEFUN([mc_CHECK_NCURSES_BY_PATH], [
  3. ac_ncurses_inc_path=[$1]
  4. ac_ncurses_lib_path=[$2]
  5. if test x"$ac_ncurses_inc_path" != x; then
  6. ac_ncurses_inc_path="-I"$ac_ncurses_inc_path
  7. fi
  8. if test x"$ac_ncurses_lib_path" != x; then
  9. ac_ncurses_lib_path="-L"$ac_ncurses_lib_path
  10. fi
  11. saved_CPPFLAGS="$CPPFLAGS"
  12. saved_LDFLAGS="$LDFLAGS"
  13. CPPFLAGS="$CPPFLAGS $ac_ncurses_inc_path"
  14. LDFLAGS="$LDFLAGS $ac_ncurses_lib_path"
  15. dnl Check for the headers
  16. dnl Both headers should be in the same directory
  17. dnl AIX term.h is unusable for mc
  18. AC_MSG_CHECKING([for ncurses/ncurses.h and ncurses/term.h])
  19. AC_PREPROC_IFELSE(
  20. [
  21. AC_LANG_PROGRAM([[#include <ncurses/ncurses.h>
  22. #include <ncurses/term.h>
  23. ]],[[return 0;]])
  24. ],
  25. [
  26. AC_MSG_RESULT(yes)
  27. if test x"$ac_ncurses_inc_path" = x; then
  28. ac_ncurses_inc_path="-I/usr/include"
  29. fi
  30. if test x"$ac_ncurses_lib_path" = x; then
  31. ac_ncurses_lib_path="-L/usr/lib"
  32. fi
  33. found_ncurses=yes
  34. AC_DEFINE(HAVE_NCURSES_NCURSES_H, 1,
  35. [Define to 1 if you have the <ncurses/ncurses.h> header file.])
  36. AC_DEFINE(HAVE_NCURSES_TERM_H, 1,
  37. [Define to 1 if you have the <ncurses/term.h> header file.])
  38. ],
  39. [
  40. AC_MSG_RESULT(no)
  41. found_ncurses=no
  42. error_msg_ncurses="ncurses header not found"
  43. ],
  44. )
  45. if test x"$found_ncurses" = x"yes"; then
  46. screen_type=ncurses
  47. screen_msg="NCurses"
  48. AC_DEFINE(HAVE_NCURSES, 1,
  49. [Define to use ncurses library for screen management])
  50. MCLIBS="$MCLIBS $ac_ncurses_lib_path"
  51. else
  52. CPPFLAGS="$saved_CPPFLAGS"
  53. LDFLAGS="$saved_LDPFLAGS"
  54. AC_MSG_ERROR([$error_msg_ncurses])
  55. fi
  56. ])
  57. dnl
  58. dnl Use the ncurses library. It can only be requested explicitly,
  59. dnl so just fail if anything goes wrong.
  60. dnl
  61. dnl If ncurses exports the ESCDELAY variable it should be set to 0
  62. dnl or you'll have to press Esc three times to dismiss a dialog box.
  63. dnl
  64. AC_DEFUN([mc_WITH_NCURSES], [
  65. dnl has_colors() is specific to ncurses, it's not in the old curses
  66. save_LIBS="$LIBS"
  67. ncursesw_found=
  68. dnl get the user supplied include path
  69. AC_ARG_WITH([ncurses-includes],
  70. AS_HELP_STRING([--with-ncurses-includes=@<:@DIR@:>@],
  71. [set path to ncurses includes @<:@default=/usr/include@:>@; make sense only if --with-screen=ncurses; for /usr/local/include/ncurses specify /usr/local/include]
  72. ),
  73. [ac_ncurses_inc_path="$withval"],
  74. [ac_ncurses_inc_path=""]
  75. )
  76. dnl get the user supplied lib path
  77. AC_ARG_WITH([ncurses-libs],
  78. AS_HELP_STRING([--with-ncurses-libs=@<:@DIR@:>@],
  79. [set path to ncurses library @<:@default=/usr/lib@:>@; make sense only if --with-screen=ncurses]
  80. ),
  81. [ac_ncurses_lib_path="$withval"],
  82. [ac_ncurses_lib_path=""]
  83. )
  84. dnl we need at least the inc path, the lib may be in a std location
  85. if test x"$ac_ncurses_inc_path" != x; then
  86. dnl check the user supplied location
  87. mc_CHECK_NCURSES_BY_PATH([$ac_ncurses_inc_path],[$ac_ncurses_lib_path])
  88. LIBS=
  89. AC_SEARCH_LIBS([has_colors], [ncurses], [MCLIBS="$MCLIBS $LIBS"],
  90. [AC_MSG_ERROR([Cannot find ncurses library])])
  91. AC_SEARCH_LIBS([stdscr], [tinfo ncurses], [MCLIBS="$MCLIBS $LIBS"],
  92. [AC_MSG_ERROR([Cannot find a library providing stdscr])])
  93. screen_type=ncurses
  94. screen_msg="NCurses"
  95. AC_DEFINE(USE_NCURSES, 1,
  96. [Define to use ncurses for screen management])
  97. else
  98. LIBS=
  99. AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes],
  100. [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
  101. AC_SEARCH_LIBS([stdscr], [tinfow tinfo ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
  102. [AC_MSG_ERROR([Cannot find a library providing stdscr])])
  103. if test x"$ncursesw_found" = "x"; then
  104. LIBS=
  105. AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
  106. [AC_MSG_ERROR([Cannot find ncurses library])])
  107. AC_SEARCH_LIBS([stdscr], [tinfo ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
  108. [AC_MSG_ERROR([Cannot find a library providing stdscr])])
  109. fi
  110. dnl Check the header
  111. ncurses_h_found=
  112. AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],
  113. [ncurses_h_found=yes; break])
  114. if test x"$ncurses_h_found" = "x"; then
  115. AC_MSG_ERROR([Cannot find ncurses header file])
  116. fi
  117. screen_type=ncurses
  118. screen_msg="NCurses"
  119. AC_DEFINE(USE_NCURSES, 1,
  120. [Define to use ncurses for screen management])
  121. fi
  122. dnl check for ESCDELAY
  123. AC_CACHE_CHECK([for ESCDELAY variable],
  124. [mc_cv_ncurses_escdelay],
  125. [AC_TRY_LINK([], [
  126. extern int ESCDELAY;
  127. ESCDELAY = 0;
  128. ],
  129. [mc_cv_ncurses_escdelay=yes],
  130. [mc_cv_ncurses_escdelay=no])
  131. ])
  132. if test x"$mc_cv_ncurses_escdelay" = xyes; then
  133. AC_DEFINE(HAVE_ESCDELAY, 1,
  134. [Define if ncurses has ESCDELAY variable])
  135. fi
  136. dnl check for resizeterm
  137. AC_CHECK_FUNCS(resizeterm)
  138. LIBS="$save_LIBS"
  139. ])
  140. dnl
  141. dnl Use the ncursesw library. It can only be requested explicitly,
  142. dnl so just fail if anything goes wrong.
  143. dnl
  144. dnl If ncursesw exports the ESCDELAY variable it should be set to 0
  145. dnl or you'll have to press Esc three times to dismiss a dialog box.
  146. dnl
  147. AC_DEFUN([mc_WITH_NCURSESW], [
  148. dnl has_colors() is specific to ncurses, it's not in the old curses
  149. save_LIBS="$LIBS"
  150. LIBS=
  151. AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
  152. [AC_MSG_ERROR([Cannot find ncursesw library])])
  153. AC_SEARCH_LIBS([stdscr], [tinfow ncursesw], [MCLIBS="$MCLIBS $LIBS"],
  154. [AC_MSG_ERROR([Cannot find a library providing stdscr])])
  155. dnl Check the header
  156. ncurses_h_found=
  157. AC_CHECK_HEADERS([ncursesw/curses.h],
  158. [ncursesw_h_found=yes; break])
  159. if test x"$ncursesw_h_found" = "x"; then
  160. AC_MSG_ERROR([Cannot find ncursesw header file])
  161. fi
  162. screen_type=ncursesw
  163. screen_msg="NCursesw"
  164. AC_DEFINE(USE_NCURSESW, 1,
  165. [Define to use ncursesw for screen management])
  166. AC_CACHE_CHECK([for ESCDELAY variable],
  167. [mc_cv_ncursesw_escdelay],
  168. [AC_TRY_LINK([], [
  169. extern int ESCDELAY;
  170. ESCDELAY = 0;
  171. ],
  172. [mc_cv_ncursesw_escdelay=yes],
  173. [mc_cv_ncursesw_escdelay=no])
  174. ])
  175. if test x"$mc_cv_ncursesw_escdelay" = xyes; then
  176. AC_DEFINE(HAVE_ESCDELAY, 1,
  177. [Define if ncursesw has ESCDELAY variable])
  178. fi
  179. AC_CHECK_FUNCS(resizeterm)
  180. LIBS="$save_LIBS"
  181. ])