3 AC_DEFUN([mc_CHECK_SLANG_HEADER], [
4 AC_MSG_CHECKING([for slang/slang.h])
7 AC_LANG_PROGRAM([#include <slang/slang.h>], [return 0;])
11 AC_DEFINE(HAVE_SLANG_SLANG_H, 1, [Define to use slang.h])
21 dnl Check if the system S-Lang library can be used.
22 dnl If not, and $1 is "strict", exit.
24 AC_DEFUN([mc_CHECK_SLANG_BY_PATH], [
26 param_slang_inc_path=[$1]
27 param_slang_lib_path=[$2]
29 if test x"$param_slang_inc_path" != x; then
30 ac_slang_inc_path="-I"$param_slang_inc_path
33 if test x"$param_slang_lib_path" != x; then
34 ac_slang_lib_path="-L"$param_slang_lib_path
37 saved_CPPFLAGS="$CPPFLAGS"
38 saved_LDFLAGS="$LDFLAGS"
40 CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path"
41 LDFLAGS="$saved_LDFLAGS $ac_slang_lib_path"
43 AC_MSG_CHECKING([for slang.h])
46 AC_LANG_PROGRAM([#include <slang.h>], [return 0;])
50 if test x"$ac_slang_inc_path" = x; then
51 ac_slang_inc_path="-I/usr/include"
53 if test x"$ac_slang_lib_path" = x; then
54 ac_slang_lib_path="-L/usr/lib"
57 AC_DEFINE(HAVE_SLANG_H, 1, [Define to use slang.h])
64 if test x"$found_slang" = xno; then
65 error_msg_slang="S-Lang header not found"
67 if test x"$ac_slang_inc_path" = x; then
68 ac_slang_inc_path="-I/usr/include"
70 if test x"$ac_slang_lib_path" = x; then
71 ac_slang_lib_path="-L/usr/lib"
73 CPPFLAGS="-DHAVE_SLANG_SLANG_H $CPPFLAGS"
77 dnl check if S-Lang have version 2.0 or newer
78 if test x"$found_slang" = x"yes"; then
79 AC_MSG_CHECKING([for S-Lang version 2.0 or newer])
80 AC_RUN_IFELSE([AC_LANG_SOURCE([
81 #ifdef HAVE_SLANG_SLANG_H
82 #include <slang/slang.h>
88 #if SLANG_VERSION >= 20000
95 [mc_slang_is_valid_version=yes],
96 [mc_slang_is_valid_version=no],
98 if test -f "$param_slang_inc_path/slang/slang.h" ; then
99 hdr_file="$param_slang_inc_path/slang/slang.h"
101 hdr_file="$param_slang_inc_path/slang.h"
103 mc_slang_is_valid_version=`grep '^#define SLANG_VERSION[[:space:]]' "$hdr_file"| sed s'/^#define SLANG_VERSION[[:space:]]*//'`
104 if test "$mc_slang_is_valid_version" -ge "20000"; then
105 mc_slang_is_valid_version=yes
107 mc_slang_is_valid_version=no
111 if test x$mc_slang_is_valid_version = xno; then
113 error_msg_slang="S-Lang library version 2.0 or newer not found"
115 AC_MSG_RESULT($mc_slang_is_valid_version)
117 dnl Check if termcap is needed.
118 dnl This check must be done before anything is linked against S-Lang.
119 if test x"$found_slang" = x"yes"; then
121 if test x"$mc_cv_slang_termcap" = x"yes"; then
122 saved_CPPFLAGS="$saved_CPPFLAGS "
123 saved_LDFLAGS="-ltermcap $saved_LDFLAGS"
126 dnl Check the library
127 unset ac_cv_lib_slang_SLang_init_tty
134 error_msg_slang="S-Lang library not found"
139 if test x"$found_slang" = x"yes"; then
141 screen_msg="S-Lang library"
143 MCLIBS="$ac_slang_lib_path -lslang $MCLIBS"
144 dnl do not reset CPPFLAGS
145 dnl if CPPFLAGS are reset then cpp does not find the specified header
146 CPPFLAGS="$ac_slang_inc_path $saved_CPPFLAGS"
147 LDFLAGS="$saved_LDFLAGS"
149 CPPFLAGS="$saved_CPPFLAGS"
150 LDFLAGS="$saved_LDFLAGS"
155 dnl Use the slang library.
157 AC_DEFUN([mc_WITH_SLANG], [
162 AC_ARG_WITH([slang-includes],
163 AS_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
164 [set path to S-Lang includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang]
166 [ac_slang_inc_path="$withval"],
167 [ac_slang_inc_path=""]
170 AC_ARG_WITH([slang-libs],
171 AS_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
172 [set path to S-Lang library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang]
174 [ac_slang_lib_path="$withval"],
175 [ac_slang_lib_path=""]
177 if test x"$ac_slang_lib_path" != x -o x"$ac_slang_inc_path" != x; then
178 echo 'checking S-Lang headers in specified place ...'
179 mc_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
182 PKG_CHECK_MODULES(SLANG, [slang >= 2.0], [found_slang=yes], [:])
183 if test x"$found_slang" = "xyes"; then
184 MCLIBS="$pkg_cv_SLANG_LIBS $MCLIBS"
185 CPPFLAGS="$pkg_cv_SLANG_CFLAGS $CPPFLAGS"
189 if test x"$found_slang" = "xno"; then
191 ac_slang_inc_path="/usr/include"
192 ac_slang_lib_path="/usr/lib"
194 echo 'checking S-Lang headers in /usr ...'
195 mc_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
196 if test x"$found_slang" = "xno"; then
198 ac_slang_inc_path="/usr/local/include"
199 ac_slang_lib_path="/usr/local/lib"
201 echo 'checking S-Lang headers in /usr/local ...'
202 mc_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
203 if test x"$found_slang" = "xno"; then
204 AC_MSG_ERROR([$error_msg_slang])
209 AC_DEFINE(HAVE_SLANG, 1, [Define to use S-Lang library for screen management])
211 mc_CHECK_SLANG_HEADER