mc-with-screen.m4 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. dnl
  2. dnl Check if the system S-Lang library can be used.
  3. dnl If not, and $1 is "strict", exit, otherwise fall back to mcslang.
  4. dnl
  5. AC_DEFUN([MC_CHECK_SLANG_BY_PATH], [
  6. ac_slang_inc_path=[$1]
  7. ac_slang_lib_path=[$2]
  8. if test x"$ac_slang_inc_path" != x; then
  9. ac_slang_inc_path="-I"$ac_slang_inc_path
  10. fi
  11. if test x"$ac_slang_lib_path" != x; then
  12. ac_slang_lib_path="-L"$ac_slang_lib_path
  13. fi
  14. saved_CFLAGS="$CFLAGS"
  15. saved_CPPFLAGS="$CPPFLAGS"
  16. saved_LDFLAGS="$LDFLAGS"
  17. CFLAGS="$CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  18. CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  19. dnl Check the header
  20. AC_MSG_CHECKING([for slang.h])
  21. AC_PREPROC_IFELSE(
  22. [
  23. AC_LANG_PROGRAM([#include <slang.h>],[return 0;])
  24. ],
  25. [
  26. AC_MSG_RESULT(yes)
  27. if test x"$ac_slang_inc_path" = x; then
  28. ac_slang_inc_path="-I/usr/include"
  29. fi
  30. if test x"$ac_slang_lib_path" = x; then
  31. ac_slang_lib_path="-L/usr/lib"
  32. fi
  33. found_slang=yes
  34. AC_DEFINE(HAVE_SLANG_H, 1,[Define to use slang.h])
  35. ],
  36. [
  37. AC_MSG_RESULT(no)
  38. AC_MSG_CHECKING([for slang/slang.h])
  39. AC_PREPROC_IFELSE(
  40. [
  41. AC_LANG_PROGRAM([#include <slang/slang.h>],[return 0;])
  42. ],
  43. [
  44. AC_MSG_RESULT(yes)
  45. if test x"$ac_slang_inc_path" = x; then
  46. ac_slang_inc_path="-I/usr/include"
  47. fi
  48. if test x"$ac_slang_lib_path" = x; then
  49. ac_slang_lib_path="-L/usr/lib"
  50. fi
  51. found_slang=yes
  52. AC_DEFINE(HAVE_SLANG_SLANG_H, 1,[Define to use slang.h])
  53. ],
  54. [
  55. AC_MSG_RESULT(no)
  56. found_slang=no
  57. error_msg_slang="Slang header not found"
  58. ]
  59. )
  60. ],
  61. )
  62. dnl Check if termcap is needed.
  63. dnl This check must be done before anything is linked against S-Lang.
  64. if test x"$found_slang" = x"yes"; then
  65. CFLAGS="$saved_CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  66. LDFLAGS="$saved_LDFLAGS $ac_slang_lib_path"
  67. CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  68. MC_SLANG_TERMCAP
  69. if test x"$mc_cv_slang_termcap" = x"yes"; then
  70. ac_slang_lib_path="$ac_slang_lib_path -ltermcap"
  71. CFLAGS="$saved_CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  72. CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  73. LDFLAGS="$saved_LDFLAGS $ac_slang_lib_path"
  74. fi
  75. fi
  76. dnl Check the library
  77. if test x"$found_slang" = x"yes"; then
  78. unset ac_cv_lib_slang_SLang_init_tty
  79. AC_CHECK_LIB(
  80. [slang],
  81. [SLang_init_tty],
  82. [:],
  83. [
  84. found_slang=no
  85. error_msg_slang="S-lang library not found"
  86. ]
  87. )
  88. fi
  89. dnl check if S-Lang have version 2.0 or newer
  90. if test x"$found_slang" = x"yes"; then
  91. AC_MSG_CHECKING([for S-Lang version 2.0 or newer])
  92. AC_TRY_RUN([
  93. #ifdef HAVE_SLANG_SLANG_H
  94. #include <slang/slang.h>
  95. #else
  96. #include <slang.h>
  97. #endif
  98. int main (void)
  99. {
  100. #if SLANG_VERSION >= 20000
  101. return 0;
  102. #else
  103. return 1;
  104. #endif
  105. }
  106. ],
  107. [mc_slang_is_valid_version=yes],
  108. [mc_slang_is_valid_version=no],
  109. [mc_slang_is_valid_version=no]
  110. )
  111. if test x$mc_slang_is_valid_version = xno; then
  112. found_slang=no
  113. error_msg_slang="S-Lang library version 2.0 or newer not found"
  114. fi
  115. AC_MSG_RESULT($mc_slang_is_valid_version)
  116. fi
  117. dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
  118. if test x"$found_slang" = x"yes"; then
  119. unset ac_cv_lib_slang_SLsmg_write_nwchars
  120. AC_CHECK_LIB(
  121. [slang],
  122. [SLsmg_write_nwchars],
  123. [
  124. found_slang=no
  125. error_msg_slang="Rejecting S-Lang with UTF-8 support, it's not fully supported yet"
  126. ],
  127. [:]
  128. )
  129. fi
  130. if test x"$found_slang" = x"yes"; then
  131. screen_type=slang
  132. screen_msg="S-Lang library (installed on the system)"
  133. AC_DEFINE(HAVE_SLANG, 1,
  134. [Define to use S-Lang library for screen management])
  135. MCLIBS="$MCLIBS $ac_slang_lib_path -lslang"
  136. fi
  137. CFLAGS="$saved_CFLAGS"
  138. CPPFLAGS="$saved_CPPFLAGS"
  139. LDFLAGS="$saved_LDFLAGS"
  140. ])
  141. dnl
  142. dnl Use the slang library.
  143. dnl
  144. AC_DEFUN([MC_WITH_SLANG], [
  145. with_screen=slang
  146. found_slang=yes
  147. error_msg_slang=""
  148. AC_ARG_WITH([slang-includes],
  149. AC_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
  150. [set path to SLANG includes @<:@default=/usr/include@:>@; may sense only if --with-screen=slang]
  151. ),
  152. [ac_slang_inc_path="$withval"],
  153. [ac_slang_inc_path=""]
  154. )
  155. AC_ARG_WITH([slang-libs],
  156. AC_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
  157. [set path to SLANG library @<:@default=/usr/lib@:>@; may sense only if --with-screen=slang]
  158. ),
  159. [ac_slang_lib_path="$withval"],
  160. [ac_slang_lib_path=""]
  161. )
  162. echo 'checking SLANG-headers in default place ...'
  163. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  164. if test x"$found_slang" = "xno"; then
  165. ac_slang_inc_path="/usr/include"
  166. ac_slang_lib_path="/usr/lib"
  167. echo 'checking SLANG-headers in /usr ...'
  168. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  169. if test x"$found_slang" = "xno"; then
  170. ac_slang_inc_path="/usr/local/include"
  171. ac_slang_lib_path="/usr/local/lib"
  172. echo 'checking SLANG-headers in /usr/local ...'
  173. MC_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
  174. if test x"$found_slang" = "xno"; then
  175. AC_MSG_ERROR([$error_msg_slang])
  176. fi
  177. fi
  178. fi
  179. ])
  180. dnl
  181. dnl Use the ncurses library. It can only be requested explicitly,
  182. dnl so just fail if anything goes wrong.
  183. dnl
  184. dnl If ncurses exports the ESCDELAY variable it should be set to 0
  185. dnl or you'll have to press Esc three times to dismiss a dialog box.
  186. dnl
  187. AC_DEFUN([MC_WITH_NCURSES], [
  188. dnl has_colors() is specific to ncurses, it's not in the old curses
  189. save_LIBS="$LIBS"
  190. ncursesw_found=
  191. LIBS=
  192. AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes],
  193. [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
  194. if test x"$ncursesw_found" = "x"; then
  195. LIBS=
  196. AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
  197. [AC_MSG_ERROR([Cannot find ncurses library])])
  198. fi
  199. dnl Check the header
  200. ncurses_h_found=
  201. AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],
  202. [ncurses_h_found=yes; break])
  203. if test x"$ncurses_h_found" = "x"; then
  204. AC_MSG_ERROR([Cannot find ncurses header file])
  205. fi
  206. screen_type=ncurses
  207. screen_msg="ncurses library"
  208. AC_DEFINE(USE_NCURSES, 1,
  209. [Define to use ncurses for screen management])
  210. AC_CACHE_CHECK([for ESCDELAY variable],
  211. [mc_cv_ncurses_escdelay],
  212. [AC_TRY_LINK([], [
  213. extern int ESCDELAY;
  214. ESCDELAY = 0;
  215. ],
  216. [mc_cv_ncurses_escdelay=yes],
  217. [mc_cv_ncurses_escdelay=no])
  218. ])
  219. if test x"$mc_cv_ncurses_escdelay" = xyes; then
  220. AC_DEFINE(HAVE_ESCDELAY, 1,
  221. [Define if ncurses has ESCDELAY variable])
  222. fi
  223. AC_CHECK_FUNCS(resizeterm)
  224. LIBS="$save_LIBS"
  225. ])
  226. dnl
  227. dnl Use the ncursesw library. It can only be requested explicitly,
  228. dnl so just fail if anything goes wrong.
  229. dnl
  230. dnl If ncursesw exports the ESCDELAY variable it should be set to 0
  231. dnl or you'll have to press Esc three times to dismiss a dialog box.
  232. dnl
  233. AC_DEFUN([MC_WITH_NCURSESW], [
  234. dnl has_colors() is specific to ncurses, it's not in the old curses
  235. save_LIBS="$LIBS"
  236. LIBS=
  237. AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
  238. [AC_MSG_ERROR([Cannot find ncursesw library])])
  239. dnl Check the header
  240. ncurses_h_found=
  241. AC_CHECK_HEADERS([ncursesw/curses.h],
  242. [ncursesw_h_found=yes; break])
  243. if test x"$ncursesw_h_found" = "x"; then
  244. AC_MSG_ERROR([Cannot find ncursesw header file])
  245. fi
  246. screen_type=ncursesw
  247. screen_msg="ncursesw library"
  248. AC_DEFINE(USE_NCURSESW, 1,
  249. [Define to use ncursesw for screen management])
  250. AC_CACHE_CHECK([for ESCDELAY variable],
  251. [mc_cv_ncursesw_escdelay],
  252. [AC_TRY_LINK([], [
  253. extern int ESCDELAY;
  254. ESCDELAY = 0;
  255. ],
  256. [mc_cv_ncursesw_escdelay=yes],
  257. [mc_cv_ncursesw_escdelay=no])
  258. ])
  259. if test x"$mc_cv_ncursesw_escdelay" = xyes; then
  260. AC_DEFINE(HAVE_ESCDELAY, 1,
  261. [Define if ncursesw has ESCDELAY variable])
  262. fi
  263. AC_CHECK_FUNCS(resizeterm)
  264. LIBS="$save_LIBS"
  265. ])