mc-with-screen-slang.m4 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. dnl Check the header
  2. AC_DEFUN([MC_CHECK_SLANG_HEADER], [
  3. AC_MSG_CHECKING([for slang/slang.h])
  4. AC_PREPROC_IFELSE(
  5. [
  6. AC_LANG_PROGRAM([#include <slang/slang.h>],[return 0;])
  7. ],
  8. [
  9. AC_MSG_RESULT(yes)
  10. AC_DEFINE(HAVE_SLANG_SLANG_H, 1,[Define to use slang.h])
  11. found_slang=yes
  12. ],
  13. [
  14. AC_MSG_RESULT(no)
  15. ]
  16. )
  17. ])
  18. dnl
  19. dnl Check if the system S-Lang library can be used.
  20. dnl If not, and $1 is "strict", exit.
  21. dnl
  22. AC_DEFUN([MC_CHECK_SLANG_BY_PATH], [
  23. param_slang_inc_path=[$1]
  24. param_slang_lib_path=[$2]
  25. if test x"$param_slang_inc_path" != x; then
  26. ac_slang_inc_path="-I"$param_slang_inc_path
  27. fi
  28. if test x"$param_slang_lib_path" != x; then
  29. ac_slang_lib_path="-L"$param_slang_lib_path
  30. fi
  31. saved_CFLAGS="$CFLAGS"
  32. saved_CPPFLAGS="$CPPFLAGS"
  33. saved_LDFLAGS="$LDFLAGS"
  34. CFLAGS="$CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  35. CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
  36. AC_MSG_CHECKING([for slang.h])
  37. AC_PREPROC_IFELSE(
  38. [
  39. AC_LANG_PROGRAM([#include <slang.h>],[return 0;])
  40. ],
  41. [
  42. AC_MSG_RESULT(yes)
  43. if test x"$ac_slang_inc_path" = x; then
  44. ac_slang_inc_path="-I/usr/include"
  45. fi
  46. if test x"$ac_slang_lib_path" = x; then
  47. ac_slang_lib_path="-L/usr/lib"
  48. fi
  49. found_slang=yes
  50. AC_DEFINE(HAVE_SLANG_H, 1,[Define to use slang.h])
  51. ],
  52. [
  53. AC_MSG_RESULT(no)
  54. MC_CHECK_SLANG_HEADER
  55. if test x"$found_slang" = xno; then
  56. error_msg_slang="Slang header not found"
  57. else
  58. if test x"$ac_slang_inc_path" = x; then
  59. ac_slang_inc_path="-I/usr/include"
  60. fi
  61. if test x"$ac_slang_lib_path" = x; then
  62. ac_slang_lib_path="-L/usr/lib"
  63. fi
  64. CFLAGS="-DHAVE_SLANG_SLANG_H $CFLAGS"
  65. fi
  66. ],
  67. )
  68. dnl check if S-Lang have version 2.0 or newer
  69. if test x"$found_slang" = x"yes"; then
  70. AC_MSG_CHECKING([for S-Lang version 2.0 or newer])
  71. AC_RUN_IFELSE([AC_LANG_SOURCE([
  72. #ifdef HAVE_SLANG_SLANG_H
  73. #include <slang/slang.h>
  74. #else
  75. #include <slang.h>
  76. #endif
  77. int main (void)
  78. {
  79. #if SLANG_VERSION >= 20000
  80. return 0;
  81. #else
  82. return 1;
  83. #endif
  84. }
  85. ])],
  86. [mc_slang_is_valid_version=yes],
  87. [mc_slang_is_valid_version=no],
  88. [
  89. if test -f "$param_slang_inc_path/slang/slang.h" ; then
  90. hdr_file="$param_slang_inc_path/slang/slang.h"
  91. else
  92. hdr_file="$param_slang_inc_path/slang.h"
  93. fi
  94. mc_slang_is_valid_version=`grep '^#define SLANG_VERSION[[:space:]]' "$hdr_file"| sed s'/^#define SLANG_VERSION[[:space:]]*//'`
  95. if test "$mc_slang_is_valid_version" -ge "20000"; then
  96. mc_slang_is_valid_version=yes
  97. else
  98. mc_slang_is_valid_version=no
  99. fi
  100. ]
  101. )
  102. if test x$mc_slang_is_valid_version = xno; then
  103. found_slang=no
  104. error_msg_slang="S-Lang library version 2.0 or newer not found"
  105. fi
  106. AC_MSG_RESULT($mc_slang_is_valid_version)
  107. fi
  108. dnl Check if termcap is needed.
  109. dnl This check must be done before anything is linked against S-Lang.
  110. if test x"$found_slang" = x"yes"; then
  111. MC_SLANG_TERMCAP
  112. if test x"$mc_cv_slang_termcap" = x"yes"; then
  113. saved_CPPFLAGS="-ltermcap $saved_CPPFLAGS "
  114. saved_LDFLAGS="-ltermcap $saved_LDFLAGS"
  115. fi
  116. dnl Check the library
  117. unset ac_cv_lib_slang_SLang_init_tty
  118. AC_CHECK_LIB(
  119. [slang],
  120. [SLang_init_tty],
  121. [:],
  122. [
  123. found_slang=no
  124. error_msg_slang="S-lang library not found"
  125. ]
  126. )
  127. fi
  128. dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
  129. if test x"$found_slang" = x"yes"; then
  130. unset ac_cv_lib_slang_SLsmg_write_nwchars
  131. AC_CHECK_LIB(
  132. [slang],
  133. [SLsmg_write_nwchars],
  134. [
  135. found_slang=no
  136. error_msg_slang="Rejecting S-Lang with UTF-8 support, it's not fully supported yet"
  137. ],
  138. [:]
  139. )
  140. fi
  141. if test x"$found_slang" = x"yes"; then
  142. screen_type=slang
  143. screen_msg="S-Lang library (installed on the system)"
  144. MCLIBS="$ac_slang_lib_path -lslang $MCLIBS"
  145. CFLAGS="$ac_slang_inc_path $saved_CFLAGS"
  146. dnl do not reset CPPFLAGS
  147. dnl - if CPPFLAGS are resetted then cpp does not find the specified header
  148. LDFLAGS="$saved_LDFLAGS"
  149. else
  150. CFLAGS="$saved_CFLAGS"
  151. CPPFLAGS="$saved_CPPFLAGS"
  152. LDFLAGS="$saved_LDFLAGS"
  153. fi
  154. ])
  155. dnl
  156. dnl Use the slang library.
  157. dnl
  158. AC_DEFUN([MC_WITH_SLANG], [
  159. with_screen=slang
  160. found_slang=yes
  161. error_msg_slang=""
  162. AC_ARG_WITH([slang-includes],
  163. AS_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
  164. [set path to SLANG includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang]
  165. ),
  166. [ac_slang_inc_path="$withval"],
  167. [ac_slang_inc_path=""]
  168. )
  169. AC_ARG_WITH([slang-libs],
  170. AS_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
  171. [set path to SLANG library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang]
  172. ),
  173. [ac_slang_lib_path="$withval"],
  174. [ac_slang_lib_path=""]
  175. )
  176. if test x"$ac_slang_lib_path" != x -o x"$ac_slang_inc_path" != x; then
  177. echo 'checking SLANG-headers in specified place ...'
  178. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  179. else
  180. found_slang=no
  181. PKG_CHECK_MODULES(SLANG, [slang >= 2.0], [found_slang=yes], [:])
  182. if test x"$found_slang" = "xyes"; then
  183. MCLIBS="$pkg_cv_SLANG_LIBS $MCLIBS"
  184. CFLAGS="$pkg_cv_SLANG_CFLAGS $CFLAGS"
  185. fi
  186. fi
  187. if test x"$found_slang" = "xno"; then
  188. found_slang=yes
  189. ac_slang_inc_path="/usr/include"
  190. ac_slang_lib_path="/usr/lib"
  191. echo 'checking SLANG-headers in /usr ...'
  192. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  193. if test x"$found_slang" = "xno"; then
  194. found_slang=yes
  195. ac_slang_inc_path="/usr/local/include"
  196. ac_slang_lib_path="/usr/local/lib"
  197. echo 'checking SLANG-headers in /usr/local ...'
  198. MC_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
  199. if test x"$found_slang" = "xno"; then
  200. AC_MSG_ERROR([$error_msg_slang])
  201. fi
  202. fi
  203. fi
  204. AC_DEFINE(HAVE_SLANG, 1,
  205. [Define to use S-Lang library for screen management])
  206. MC_CHECK_SLANG_HEADER
  207. ])