mc-with-screen-slang.m4 5.8 KB

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