mc-with-screen-ncurses.m4 6.4 KB

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