mc-with-screen-slang.m4 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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="S-Lang 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. if test x"$found_slang" = x"yes"; then
  129. screen_type=slang
  130. screen_msg="S-Lang library"
  131. MCLIBS="$ac_slang_lib_path -lslang $MCLIBS"
  132. CFLAGS="$ac_slang_inc_path $saved_CFLAGS"
  133. dnl do not reset CPPFLAGS
  134. dnl - if CPPFLAGS are reset then cpp does not find the specified header
  135. LDFLAGS="$saved_LDFLAGS"
  136. else
  137. CFLAGS="$saved_CFLAGS"
  138. CPPFLAGS="$saved_CPPFLAGS"
  139. LDFLAGS="$saved_LDFLAGS"
  140. fi
  141. ])
  142. dnl
  143. dnl Use the slang library.
  144. dnl
  145. AC_DEFUN([MC_WITH_SLANG], [
  146. with_screen=slang
  147. found_slang=yes
  148. error_msg_slang=""
  149. AC_ARG_WITH([slang-includes],
  150. AS_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
  151. [set path to S-Lang includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang]
  152. ),
  153. [ac_slang_inc_path="$withval"],
  154. [ac_slang_inc_path=""]
  155. )
  156. AC_ARG_WITH([slang-libs],
  157. AS_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
  158. [set path to S-Lang library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang]
  159. ),
  160. [ac_slang_lib_path="$withval"],
  161. [ac_slang_lib_path=""]
  162. )
  163. if test x"$ac_slang_lib_path" != x -o x"$ac_slang_inc_path" != x; then
  164. echo 'checking S-Lang headers in specified place ...'
  165. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  166. else
  167. found_slang=no
  168. PKG_CHECK_MODULES(SLANG, [slang >= 2.0], [found_slang=yes], [:])
  169. if test x"$found_slang" = "xyes"; then
  170. MCLIBS="$pkg_cv_SLANG_LIBS $MCLIBS"
  171. CFLAGS="$pkg_cv_SLANG_CFLAGS $CFLAGS"
  172. fi
  173. fi
  174. if test x"$found_slang" = "xno"; then
  175. found_slang=yes
  176. ac_slang_inc_path="/usr/include"
  177. ac_slang_lib_path="/usr/lib"
  178. echo 'checking S-Lang headers in /usr ...'
  179. MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
  180. if test x"$found_slang" = "xno"; then
  181. found_slang=yes
  182. ac_slang_inc_path="/usr/local/include"
  183. ac_slang_lib_path="/usr/local/lib"
  184. echo 'checking S-Lang headers in /usr/local ...'
  185. MC_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
  186. if test x"$found_slang" = "xno"; then
  187. AC_MSG_ERROR([$error_msg_slang])
  188. fi
  189. fi
  190. fi
  191. AC_DEFINE(HAVE_SLANG, 1, [Define to use S-Lang library for screen management])
  192. MC_CHECK_SLANG_HEADER
  193. ])