mc-with-screen.m4 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. dnl
  2. dnl Check if the system S-Lang library can be used.
  3. dnl If not, and $1 is "strict", exit.
  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. CFLAGS="$saved_CFLAGS"
  137. dnl do not reset CPPFLAGS
  138. dnl - if CPPFLAGS are resetted then cpp does not find the specified header
  139. LDFLAGS="$saved_LDFLAGS"
  140. else
  141. CFLAGS="$saved_CFLAGS"
  142. CPPFLAGS="$saved_CPPFLAGS"
  143. LDFLAGS="$saved_LDFLAGS"
  144. fi
  145. ])
  146. dnl
  147. dnl Use the slang library.
  148. dnl
  149. AC_DEFUN([MC_WITH_SLANG], [
  150. with_screen=slang
  151. found_slang=yes
  152. error_msg_slang=""
  153. AC_ARG_WITH([slang-includes],
  154. AC_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
  155. [set path to SLANG includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang]
  156. ),
  157. [ac_slang_inc_path="$withval"],
  158. [ac_slang_inc_path=""]
  159. )
  160. AC_ARG_WITH([slang-libs],
  161. AC_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
  162. [set path to SLANG library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang]
  163. ),
  164. [ac_slang_lib_path="$withval"],
  165. [ac_slang_lib_path=""]
  166. )
  167. echo 'checking SLANG-headers in default place ...'
  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/include"
  171. ac_slang_lib_path="/usr/lib"
  172. echo 'checking SLANG-headers in /usr ...'
  173. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  174. if test x"$found_slang" = "xno"; then
  175. ac_slang_inc_path="/usr/local/include"
  176. ac_slang_lib_path="/usr/local/lib"
  177. echo 'checking SLANG-headers in /usr/local ...'
  178. MC_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
  179. if test x"$found_slang" = "xno"; then
  180. AC_MSG_ERROR([$error_msg_slang])
  181. fi
  182. fi
  183. fi
  184. ])
  185. dnl check for ncurses in user supplied path
  186. AC_DEFUN([MC_CHECK_NCURSES_BY_PATH], [
  187. ac_ncurses_inc_path=[$1]
  188. ac_ncurses_lib_path=[$2]
  189. if test x"$ac_ncurses_inc_path" != x; then
  190. ac_ncurses_inc_path="-I"$ac_ncurses_inc_path
  191. fi
  192. if test x"$ac_ncurses_lib_path" != x; then
  193. ac_ncurses_lib_path="-L"$ac_ncurses_lib_path
  194. fi
  195. saved_CPPFLAGS="$CPPFLAGS"
  196. CPPFLAGS="$CPPFLAGS $ac_ncurses_inc_path"
  197. dnl Check for the headers
  198. dnl Both headers should be in the same directory
  199. dnl AIX term.h is unusable for mc
  200. AC_MSG_CHECKING([for ncurses/ncurses.h and ncurses/term.h])
  201. AC_PREPROC_IFELSE(
  202. [
  203. AC_LANG_PROGRAM([[#include <ncurses/ncurses.h>
  204. #include <ncurses/term.h>
  205. ]],[[return 0;]])
  206. ],
  207. [
  208. AC_MSG_RESULT(yes)
  209. if test x"$ac_ncurses_inc_path" = x; then
  210. ac_ncurses_inc_path="-I/usr/include"
  211. fi
  212. if test x"$ac_ncurses_lib_path" = x; then
  213. ac_ncurses_lib_path="-L/usr/lib"
  214. fi
  215. found_ncurses=yes
  216. AC_DEFINE(HAVE_NCURSES_NCURSES_H, 1,
  217. [Define to 1 if you have the <ncurses/ncurses.h> header file.])
  218. AC_DEFINE(HAVE_NCURSES_TERM_H, 1,
  219. [Define to 1 if you have the <ncurses/term.h> header file.])
  220. ],
  221. [
  222. AC_MSG_RESULT(no)
  223. found_ncurses=no
  224. error_msg_ncurses="ncurses header not found"
  225. ],
  226. )
  227. if test x"$found_ncurses" = x"yes"; then
  228. screen_type=ncurses
  229. screen_msg="ncurses library (installed on the system)"
  230. AC_DEFINE(HAVE_NCURSES, 1,
  231. [Define to use ncurses library for screen management])
  232. MCLIBS="$MCLIBS $ac_ncurses_lib_path"
  233. else
  234. CPPFLAGS="$saved_CPPFLAGS"
  235. AC_MSG_ERROR([$error_msg_ncurses])
  236. fi
  237. ])
  238. dnl
  239. dnl Use the ncurses library. It can only be requested explicitly,
  240. dnl so just fail if anything goes wrong.
  241. dnl
  242. dnl If ncurses exports the ESCDELAY variable it should be set to 0
  243. dnl or you'll have to press Esc three times to dismiss a dialog box.
  244. dnl
  245. AC_DEFUN([MC_WITH_NCURSES], [
  246. dnl has_colors() is specific to ncurses, it's not in the old curses
  247. save_LIBS="$LIBS"
  248. ncursesw_found=
  249. dnl get the user supplied include path
  250. AC_ARG_WITH([ncurses-includes],
  251. AC_HELP_STRING([--with-ncurses-includes=@<:@DIR@:>@],
  252. [set path to ncurses includes @<:@default=/usr/include@:>@; make sense only if --with-screen=ncurses; for /usr/local/include/ncurses specify /usr/local/include]
  253. ),
  254. [ac_ncurses_inc_path="$withval"],
  255. [ac_ncurses_inc_path=""]
  256. )
  257. dnl get the user supplied lib path
  258. AC_ARG_WITH([ncurses-libs],
  259. AC_HELP_STRING([--with-ncurses-libs=@<:@DIR@:>@],
  260. [set path to ncurses library @<:@default=/usr/lib@:>@; make sense only if --with-screen=ncurses]
  261. ),
  262. [ac_ncurses_lib_path="$withval"],
  263. [ac_ncurses_lib_path=""]
  264. )
  265. dnl we need at least the inc path, the lib may be in a std location
  266. if test x"$ac_ncurses_inc_path" != x; then
  267. dnl check the user supplied location
  268. MC_CHECK_NCURSES_BY_PATH([$ac_ncurses_inc_path],[$ac_ncurses_lib_path])
  269. LIBS=
  270. AC_SEARCH_LIBS([has_colors], [ncurses], [MCLIBS="$MCLIBS $LIBS"],
  271. [AC_MSG_ERROR([Cannot find ncurses library])])
  272. screen_type=ncurses
  273. screen_msg="ncurses library"
  274. AC_DEFINE(USE_NCURSES, 1,
  275. [Define to use ncurses for screen management])
  276. else
  277. LIBS=
  278. AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes],
  279. [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
  280. if test x"$ncursesw_found" = "x"; then
  281. LIBS=
  282. AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
  283. [AC_MSG_ERROR([Cannot find ncurses library])])
  284. fi
  285. dnl Check the header
  286. ncurses_h_found=
  287. AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],
  288. [ncurses_h_found=yes; break])
  289. if test x"$ncurses_h_found" = "x"; then
  290. AC_MSG_ERROR([Cannot find ncurses header file])
  291. fi
  292. screen_type=ncurses
  293. screen_msg="ncurses library"
  294. AC_DEFINE(USE_NCURSES, 1,
  295. [Define to use ncurses for screen management])
  296. fi
  297. dnl check for ESCDELAY
  298. AC_CACHE_CHECK([for ESCDELAY variable],
  299. [mc_cv_ncurses_escdelay],
  300. [AC_TRY_LINK([], [
  301. extern int ESCDELAY;
  302. ESCDELAY = 0;
  303. ],
  304. [mc_cv_ncurses_escdelay=yes],
  305. [mc_cv_ncurses_escdelay=no])
  306. ])
  307. if test x"$mc_cv_ncurses_escdelay" = xyes; then
  308. AC_DEFINE(HAVE_ESCDELAY, 1,
  309. [Define if ncurses has ESCDELAY variable])
  310. fi
  311. dnl check for resizeterm
  312. AC_CHECK_FUNCS(resizeterm)
  313. LIBS="$save_LIBS"
  314. ])
  315. dnl
  316. dnl Use the ncursesw library. It can only be requested explicitly,
  317. dnl so just fail if anything goes wrong.
  318. dnl
  319. dnl If ncursesw exports the ESCDELAY variable it should be set to 0
  320. dnl or you'll have to press Esc three times to dismiss a dialog box.
  321. dnl
  322. AC_DEFUN([MC_WITH_NCURSESW], [
  323. dnl has_colors() is specific to ncurses, it's not in the old curses
  324. save_LIBS="$LIBS"
  325. LIBS=
  326. AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
  327. [AC_MSG_ERROR([Cannot find ncursesw library])])
  328. dnl Check the header
  329. ncurses_h_found=
  330. AC_CHECK_HEADERS([ncursesw/curses.h],
  331. [ncursesw_h_found=yes; break])
  332. if test x"$ncursesw_h_found" = "x"; then
  333. AC_MSG_ERROR([Cannot find ncursesw header file])
  334. fi
  335. screen_type=ncursesw
  336. screen_msg="ncursesw library"
  337. AC_DEFINE(USE_NCURSESW, 1,
  338. [Define to use ncursesw for screen management])
  339. AC_CACHE_CHECK([for ESCDELAY variable],
  340. [mc_cv_ncursesw_escdelay],
  341. [AC_TRY_LINK([], [
  342. extern int ESCDELAY;
  343. ESCDELAY = 0;
  344. ],
  345. [mc_cv_ncursesw_escdelay=yes],
  346. [mc_cv_ncursesw_escdelay=no])
  347. ])
  348. if test x"$mc_cv_ncursesw_escdelay" = xyes; then
  349. AC_DEFINE(HAVE_ESCDELAY, 1,
  350. [Define if ncursesw has ESCDELAY variable])
  351. fi
  352. AC_CHECK_FUNCS(resizeterm)
  353. LIBS="$save_LIBS"
  354. ])