mc-with-screen-ncurses.m4 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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="$MCLIBS"
  89. AC_SEARCH_LIBS([has_colors], [ncurses], [],
  90. [AC_MSG_ERROR([Cannot find ncurses library])])
  91. AC_SEARCH_LIBS([stdscr], [tinfo], [],
  92. [AC_MSG_ERROR([Cannot find a library providing stdscr])])
  93. MCLIBS="$LIBS"
  94. screen_type=ncurses
  95. screen_msg="NCurses"
  96. AC_DEFINE(USE_NCURSES, 1,
  97. [Define to use ncurses for screen management])
  98. else
  99. LIBS="$MCLIBS"
  100. AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [ncursesw_found=yes],
  101. [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
  102. MCLIBS="$LIBS"
  103. if test x"$ncursesw_found" = "x"; then
  104. LIBS="$MCLIBS"
  105. AC_SEARCH_LIBS([has_colors], [ncurses curses], [],
  106. [AC_MSG_ERROR([Cannot find ncurses library])])
  107. MCLIBS="$LIBS"
  108. fi
  109. LIBS="$MCLIBS"
  110. AC_SEARCH_LIBS([stdscr], [tinfow tinfo], [],
  111. [AC_MSG_ERROR([Cannot find a library providing stdscr])])
  112. MCLIBS="$LIBS"
  113. dnl Check the header
  114. ncurses_h_found=
  115. AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],
  116. [ncurses_h_found=yes; break])
  117. if test x"$ncurses_h_found" = "x"; then
  118. AC_MSG_ERROR([Cannot find ncurses header file])
  119. fi
  120. AC_CHECK_HEADERS([ncurses/term.h])
  121. screen_type=ncurses
  122. screen_msg="NCurses"
  123. AC_DEFINE(USE_NCURSES, 1,
  124. [Define to use ncurses for screen management])
  125. fi
  126. dnl check for ESCDELAY
  127. AC_CACHE_CHECK([for ESCDELAY variable],
  128. [mc_cv_ncurses_escdelay],
  129. [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  130. extern int ESCDELAY;
  131. ESCDELAY = 0;
  132. ]])],
  133. [mc_cv_ncurses_escdelay=yes],
  134. [mc_cv_ncurses_escdelay=no])
  135. ])
  136. if test x"$mc_cv_ncurses_escdelay" = xyes; then
  137. AC_DEFINE(HAVE_ESCDELAY, 1,
  138. [Define if ncurses has ESCDELAY variable])
  139. fi
  140. dnl check for resizeterm
  141. AC_CHECK_FUNCS(resizeterm)
  142. LIBS="$save_LIBS"
  143. ])
  144. dnl
  145. dnl Use the ncursesw library. It can only be requested explicitly,
  146. dnl so just fail if anything goes wrong.
  147. dnl
  148. dnl If ncursesw exports the ESCDELAY variable it should be set to 0
  149. dnl or you'll have to press Esc three times to dismiss a dialog box.
  150. dnl
  151. AC_DEFUN([mc_WITH_NCURSESW], [
  152. dnl has_colors() is specific to ncurses, it's not in the old curses
  153. save_LIBS="$LIBS"
  154. LIBS=
  155. AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
  156. [AC_MSG_ERROR([Cannot find ncursesw library])])
  157. AC_SEARCH_LIBS([stdscr], [tinfow ncursesw], [MCLIBS="$MCLIBS $LIBS"],
  158. [AC_MSG_ERROR([Cannot find a library providing stdscr])])
  159. dnl Check the header
  160. ncurses_h_found=
  161. AC_CHECK_HEADERS([ncursesw/curses.h],
  162. [ncursesw_h_found=yes; break])
  163. if test x"$ncursesw_h_found" = "x"; then
  164. AC_MSG_ERROR([Cannot find ncursesw header file])
  165. fi
  166. screen_type=ncursesw
  167. screen_msg="NCursesw"
  168. AC_DEFINE(USE_NCURSESW, 1,
  169. [Define to use ncursesw for screen management])
  170. AC_CACHE_CHECK([for ESCDELAY variable],
  171. [mc_cv_ncursesw_escdelay],
  172. [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  173. extern int ESCDELAY;
  174. ESCDELAY = 0;
  175. ]])],
  176. [mc_cv_ncursesw_escdelay=yes],
  177. [mc_cv_ncursesw_escdelay=no])
  178. ])
  179. if test x"$mc_cv_ncursesw_escdelay" = xyes; then
  180. AC_DEFINE(HAVE_ESCDELAY, 1,
  181. [Define if ncursesw has ESCDELAY variable])
  182. fi
  183. AC_CHECK_FUNCS(resizeterm)
  184. LIBS="$save_LIBS"
  185. ])