mc-with-screen-slang.m4 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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_CPPFLAGS="$CPPFLAGS"
  32. saved_LDFLAGS="$LDFLAGS"
  33. CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path"
  34. LDFLAGS="$saved_LDFLAGS $ac_slang_lib_path"
  35. AC_MSG_CHECKING([for slang.h])
  36. AC_PREPROC_IFELSE(
  37. [
  38. AC_LANG_PROGRAM([#include <slang.h>], [return 0;])
  39. ],
  40. [
  41. AC_MSG_RESULT(yes)
  42. if test x"$ac_slang_inc_path" = x; then
  43. ac_slang_inc_path="-I/usr/include"
  44. fi
  45. if test x"$ac_slang_lib_path" = x; then
  46. ac_slang_lib_path="-L/usr/lib"
  47. fi
  48. found_slang=yes
  49. AC_DEFINE(HAVE_SLANG_H, 1, [Define to use slang.h])
  50. ],
  51. [
  52. AC_MSG_RESULT(no)
  53. MC_CHECK_SLANG_HEADER
  54. if test x"$found_slang" = xno; then
  55. error_msg_slang="S-Lang header not found"
  56. else
  57. if test x"$ac_slang_inc_path" = x; then
  58. ac_slang_inc_path="-I/usr/include"
  59. fi
  60. if test x"$ac_slang_lib_path" = x; then
  61. ac_slang_lib_path="-L/usr/lib"
  62. fi
  63. CPPFLAGS="-DHAVE_SLANG_SLANG_H $CPPFLAGS"
  64. fi
  65. ],
  66. )
  67. dnl check if S-Lang have version 2.0 or newer
  68. if test x"$found_slang" = x"yes"; then
  69. AC_MSG_CHECKING([for S-Lang version 2.0 or newer])
  70. AC_RUN_IFELSE([AC_LANG_SOURCE([
  71. #ifdef HAVE_SLANG_SLANG_H
  72. #include <slang/slang.h>
  73. #else
  74. #include <slang.h>
  75. #endif
  76. int main (void)
  77. {
  78. #if SLANG_VERSION >= 20000
  79. return 0;
  80. #else
  81. return 1;
  82. #endif
  83. }
  84. ])],
  85. [mc_slang_is_valid_version=yes],
  86. [mc_slang_is_valid_version=no],
  87. [
  88. if test -f "$param_slang_inc_path/slang/slang.h" ; then
  89. hdr_file="$param_slang_inc_path/slang/slang.h"
  90. else
  91. hdr_file="$param_slang_inc_path/slang.h"
  92. fi
  93. mc_slang_is_valid_version=`grep '^#define SLANG_VERSION[[:space:]]' "$hdr_file"| sed s'/^#define SLANG_VERSION[[:space:]]*//'`
  94. if test "$mc_slang_is_valid_version" -ge "20000"; then
  95. mc_slang_is_valid_version=yes
  96. else
  97. mc_slang_is_valid_version=no
  98. fi
  99. ]
  100. )
  101. if test x$mc_slang_is_valid_version = xno; then
  102. found_slang=no
  103. error_msg_slang="S-Lang library version 2.0 or newer not found"
  104. fi
  105. AC_MSG_RESULT($mc_slang_is_valid_version)
  106. fi
  107. dnl Check if termcap is needed.
  108. dnl This check must be done before anything is linked against S-Lang.
  109. if test x"$found_slang" = x"yes"; then
  110. MC_SLANG_TERMCAP
  111. if test x"$mc_cv_slang_termcap" = x"yes"; then
  112. saved_CPPFLAGS="$saved_CPPFLAGS "
  113. saved_LDFLAGS="-ltermcap $saved_LDFLAGS"
  114. fi
  115. dnl Check the library
  116. unset ac_cv_lib_slang_SLang_init_tty
  117. AC_CHECK_LIB(
  118. [slang],
  119. [SLang_init_tty],
  120. [:],
  121. [
  122. found_slang=no
  123. error_msg_slang="S-Lang library not found"
  124. ]
  125. )
  126. fi
  127. if test x"$found_slang" = x"yes"; then
  128. screen_type=slang
  129. screen_msg="S-Lang library"
  130. MCLIBS="$ac_slang_lib_path -lslang $MCLIBS"
  131. dnl do not reset CPPFLAGS
  132. dnl if CPPFLAGS are reset then cpp does not find the specified header
  133. CPPFLAGS="$ac_slang_inc_path $saved_CPPFLAGS"
  134. LDFLAGS="$saved_LDFLAGS"
  135. else
  136. CPPFLAGS="$saved_CPPFLAGS"
  137. LDFLAGS="$saved_LDFLAGS"
  138. fi
  139. ])
  140. dnl
  141. dnl Use the slang library.
  142. dnl
  143. AC_DEFUN([MC_WITH_SLANG], [
  144. with_screen=slang
  145. found_slang=yes
  146. error_msg_slang=""
  147. AC_ARG_WITH([slang-includes],
  148. AS_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
  149. [set path to S-Lang includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang]
  150. ),
  151. [ac_slang_inc_path="$withval"],
  152. [ac_slang_inc_path=""]
  153. )
  154. AC_ARG_WITH([slang-libs],
  155. AS_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
  156. [set path to S-Lang library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang]
  157. ),
  158. [ac_slang_lib_path="$withval"],
  159. [ac_slang_lib_path=""]
  160. )
  161. if test x"$ac_slang_lib_path" != x -o x"$ac_slang_inc_path" != x; then
  162. echo 'checking S-Lang headers in specified place ...'
  163. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  164. else
  165. found_slang=no
  166. PKG_CHECK_MODULES(SLANG, [slang >= 2.0], [found_slang=yes], [:])
  167. if test x"$found_slang" = "xyes"; then
  168. MCLIBS="$pkg_cv_SLANG_LIBS $MCLIBS"
  169. CPPFLAGS="$pkg_cv_SLANG_CFLAGS $CPPFLAGS"
  170. fi
  171. fi
  172. if test x"$found_slang" = "xno"; then
  173. found_slang=yes
  174. ac_slang_inc_path="/usr/include"
  175. ac_slang_lib_path="/usr/lib"
  176. echo 'checking S-Lang headers in /usr ...'
  177. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  178. if test x"$found_slang" = "xno"; then
  179. found_slang=yes
  180. ac_slang_inc_path="/usr/local/include"
  181. ac_slang_lib_path="/usr/local/lib"
  182. echo 'checking S-Lang headers in /usr/local ...'
  183. MC_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
  184. if test x"$found_slang" = "xno"; then
  185. AC_MSG_ERROR([$error_msg_slang])
  186. fi
  187. fi
  188. fi
  189. AC_DEFINE(HAVE_SLANG, 1, [Define to use S-Lang library for screen management])
  190. MC_CHECK_SLANG_HEADER
  191. ])