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_CFLAGS="$CFLAGS"
38 saved_CPPFLAGS="$CPPFLAGS"
39 saved_LDFLAGS="$LDFLAGS"
41 CFLAGS="$CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
42 CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
44 AC_MSG_CHECKING([for slang.h])
47 AC_LANG_PROGRAM([#include <slang.h>],[return 0;])
51 if test x"$ac_slang_inc_path" = x; then
52 ac_slang_inc_path="-I/usr/include"
54 if test x"$ac_slang_lib_path" = x; then
55 ac_slang_lib_path="-L/usr/lib"
58 AC_DEFINE(HAVE_SLANG_H, 1,[Define to use slang.h])
65 if test x"$found_slang" = xno; then
66 error_msg_slang="Slang header not found"
68 if test x"$ac_slang_inc_path" = x; then
69 ac_slang_inc_path="-I/usr/include"
71 if test x"$ac_slang_lib_path" = x; then
72 ac_slang_lib_path="-L/usr/lib"
74 CFLAGS="-DHAVE_SLANG_SLANG_H $CFLAGS"
78 dnl check if S-Lang have version 2.0 or newer
79 if test x"$found_slang" = x"yes"; then
80 AC_MSG_CHECKING([for S-Lang version 2.0 or newer])
82 #ifdef HAVE_SLANG_SLANG_H
83 #include <slang/slang.h>
89 #if SLANG_VERSION >= 20000
96 [mc_slang_is_valid_version=yes],
97 [mc_slang_is_valid_version=no],
99 if test -f "$param_slang_inc_path/slang/slang.h" ; then
100 hdr_file="$param_slang_inc_path/slang/slang.h"
102 hdr_file="$param_slang_inc_path/slang.h"
104 mc_slang_is_valid_version=`grep '^#define SLANG_VERSION[[:space:]]' "$hdr_file"| sed s'/^#define SLANG_VERSION[[:space:]]*//'`
105 if test "$mc_slang_is_valid_version" -ge "20000"; then
106 mc_slang_is_valid_version=yes
108 mc_slang_is_valid_version=no
112 if test x$mc_slang_is_valid_version = xno; then
114 error_msg_slang="S-Lang library version 2.0 or newer not found"
116 AC_MSG_RESULT($mc_slang_is_valid_version)
118 dnl Check if termcap is needed.
119 dnl This check must be done before anything is linked against S-Lang.
120 if test x"$found_slang" = x"yes"; then
122 if test x"$mc_cv_slang_termcap" = x"yes"; then
123 saved_CPPFLAGS="-ltermcap $saved_CPPFLAGS "
124 saved_LDFLAGS="-ltermcap $saved_LDFLAGS"
128 dnl Check the library
129 unset ac_cv_lib_slang_SLang_init_tty
136 error_msg_slang="S-lang library not found"
141 dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
142 if test x"$found_slang" = x"yes"; then
143 unset ac_cv_lib_slang_SLsmg_write_nwchars
146 [SLsmg_write_nwchars],
149 error_msg_slang="Rejecting S-Lang with UTF-8 support, it's not fully supported yet"
155 if test x"$found_slang" = x"yes"; then
157 screen_msg="S-Lang library (installed on the system)"
159 MCLIBS="$ac_slang_lib_path -lslang $MCLIBS"
160 CFLAGS="$ac_slang_inc_path $saved_CFLAGS"
161 dnl do not reset CPPFLAGS
162 dnl - if CPPFLAGS are resetted then cpp does not find the specified header
163 LDFLAGS="$saved_LDFLAGS"
165 CFLAGS="$saved_CFLAGS"
166 CPPFLAGS="$saved_CPPFLAGS"
167 LDFLAGS="$saved_LDFLAGS"
172 dnl Use the slang library.
174 AC_DEFUN([MC_WITH_SLANG], [
179 AC_ARG_WITH([slang-includes],
180 AC_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
181 [set path to SLANG includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang]
183 [ac_slang_inc_path="$withval"],
184 [ac_slang_inc_path=""]
187 AC_ARG_WITH([slang-libs],
188 AC_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
189 [set path to SLANG library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang]
191 [ac_slang_lib_path="$withval"],
192 [ac_slang_lib_path=""]
194 if test x"$ac_slang_lib_path" != x -o x"$ac_slang_inc_path" != x; then
195 echo 'checking SLANG-headers in specified place ...'
196 MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
199 PKG_CHECK_MODULES(SLANG, [slang >= 2.0], [found_slang=yes], [:])
200 if test x"$found_slang" = "xyes"; then
201 MCLIBS="$pkg_cv_SLANG_LIBS $MCLIBS"
202 CFLAGS="$pkg_cv_SLANG_CFLAGS $CFLAGS"
206 if test x"$found_slang" = "xno"; then
208 ac_slang_inc_path="/usr/include"
209 ac_slang_lib_path="/usr/lib"
211 echo 'checking SLANG-headers in /usr ...'
212 MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
213 if test x"$found_slang" = "xno"; then
215 ac_slang_inc_path="/usr/local/include"
216 ac_slang_lib_path="/usr/local/lib"
218 echo 'checking SLANG-headers in /usr/local ...'
219 MC_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
220 if test x"$found_slang" = "xno"; then
221 AC_MSG_ERROR([$error_msg_slang])
226 AC_DEFINE(HAVE_SLANG, 1,
227 [Define to use S-Lang library for screen management])
229 MC_CHECK_SLANG_HEADER