mc-with-screen-ncurses.m4 6.5 KB

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