Ticket #3828: syntax: Apache Hive query language
[midnight-commander.git] / m4.include / mc-with-screen-slang.m4
blobfeaa9b997ceb2520302c89bf98946a659bf0e87f
2 dnl Check the header
3 AC_DEFUN([mc_CHECK_SLANG_HEADER], [
4     AC_MSG_CHECKING([for slang/slang.h])
5     AC_PREPROC_IFELSE(
6         [
7             AC_LANG_PROGRAM([#include <slang/slang.h>], [return 0;])
8         ],
9         [
10             AC_MSG_RESULT(yes)
11             AC_DEFINE(HAVE_SLANG_SLANG_H, 1, [Define to use slang.h])
12             found_slang=yes
13         ],
14         [
15             AC_MSG_RESULT(no)
16         ]
17     )
20 dnl
21 dnl Check if the system S-Lang library can be used.
22 dnl If not, and $1 is "strict", exit.
23 dnl
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
31     fi
33     if test x"$param_slang_lib_path" != x; then
34         ac_slang_lib_path="-L"$param_slang_lib_path
35     fi
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])
44     AC_PREPROC_IFELSE(
45         [
46             AC_LANG_PROGRAM([#include <slang.h>], [return 0;])
47         ],
48         [
49             AC_MSG_RESULT(yes)
50             if test x"$ac_slang_inc_path" = x; then
51                 ac_slang_inc_path="-I/usr/include"
52             fi
53             if test x"$ac_slang_lib_path" = x; then
54                 ac_slang_lib_path="-L/usr/lib"
55             fi
56             found_slang=yes
57             AC_DEFINE(HAVE_SLANG_H, 1, [Define to use slang.h])
59         ],
60         [
61             AC_MSG_RESULT(no)
63             mc_CHECK_SLANG_HEADER
64             if test x"$found_slang" = xno; then
65                 error_msg_slang="S-Lang header not found"
66             else
67                 if test x"$ac_slang_inc_path" = x; then
68                     ac_slang_inc_path="-I/usr/include"
69                 fi
70                 if test x"$ac_slang_lib_path" = x; then
71                     ac_slang_lib_path="-L/usr/lib"
72                 fi
73                 CPPFLAGS="-DHAVE_SLANG_SLANG_H $CPPFLAGS"
74             fi
75         ],
76     )
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>
83 #else
84 #include <slang.h>
85 #endif
86 int main (void)
88 #if SLANG_VERSION >= 20000
89     return 0;
90 #else
91     return 1;
92 #endif
94 ])],
95             [mc_slang_is_valid_version=yes],
96             [mc_slang_is_valid_version=no],
97             [
98             if test -f "$param_slang_inc_path/slang/slang.h" ; then
99                 hdr_file="$param_slang_inc_path/slang/slang.h"
100             else
101                 hdr_file="$param_slang_inc_path/slang.h"
102             fi
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
106             else
107                 mc_slang_is_valid_version=no
108             fi
109             ]
110         )
111         if test x$mc_slang_is_valid_version = xno; then
112             found_slang=no
113             error_msg_slang="S-Lang library version 2.0 or newer not found"
114         fi
115         AC_MSG_RESULT($mc_slang_is_valid_version)
116     fi
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
120         mc_SLANG_TERMCAP
121         if test x"$mc_cv_slang_termcap"  = x"yes"; then
122             saved_CPPFLAGS="$saved_CPPFLAGS "
123             saved_LDFLAGS="-ltermcap $saved_LDFLAGS"
124         fi
126         dnl Check the library
127         unset ac_cv_lib_slang_SLang_init_tty
128         AC_CHECK_LIB(
129             [slang],
130             [SLang_init_tty],
131             [:],
132             [
133                 found_slang=no
134                 error_msg_slang="S-Lang library not found"
135             ]
136         )
137     fi
139     if test x"$found_slang" = x"yes"; then
140         MCLIBS="$ac_slang_lib_path -lslang $MCLIBS"
141         dnl do not reset CPPFLAGS
142         dnl if CPPFLAGS are reset then cpp does not find the specified header
143         CPPFLAGS="$ac_slang_inc_path $saved_CPPFLAGS"
144         LDFLAGS="$saved_LDFLAGS"
145     else
146         CPPFLAGS="$saved_CPPFLAGS"
147         LDFLAGS="$saved_LDFLAGS"
148     fi
152 dnl Use the slang library.
154 AC_DEFUN([mc_WITH_SLANG], [
155     with_screen=slang
156     found_slang=yes
157     error_msg_slang=""
159     AC_ARG_WITH([slang-includes],
160         AS_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
161             [set path to S-Lang includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang]
162         ),
163         [ac_slang_inc_path="$withval"],
164         [ac_slang_inc_path=""]
165     )
167     AC_ARG_WITH([slang-libs],
168         AS_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
169             [set path to S-Lang library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang]
170         ),
171         [ac_slang_lib_path="$withval"],
172         [ac_slang_lib_path=""]
173     )
174     if test x"$ac_slang_lib_path" != x -o x"$ac_slang_inc_path" != x; then
175         echo 'checking S-Lang headers in specified place ...'
176         mc_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
177     else
178         found_slang=no
179         PKG_CHECK_MODULES(SLANG, [slang >= 2.0], [found_slang=yes], [:])
180         if test x"$found_slang" = "xyes"; then
181             MCLIBS="$pkg_cv_SLANG_LIBS $MCLIBS"
182             CPPFLAGS="$pkg_cv_SLANG_CFLAGS $CPPFLAGS"
183         fi
184     fi
186     if test x"$found_slang" = "xno"; then
187         found_slang=yes
188         ac_slang_inc_path="/usr/include"
189         ac_slang_lib_path="/usr/lib"
191         echo 'checking S-Lang headers in /usr ...'
192         mc_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
193         if test x"$found_slang" = "xno"; then
194             found_slang=yes
195             ac_slang_inc_path="/usr/local/include"
196             ac_slang_lib_path="/usr/local/lib"
198             echo 'checking S-Lang headers in /usr/local ...'
199             mc_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
200             if test x"$found_slang" = "xno"; then
201                 AC_MSG_ERROR([$error_msg_slang])
202             fi
203         fi
204     fi
206     screen_type=slang
207     screen_msg="S-Lang"
208     AC_DEFINE(HAVE_SLANG, 1, [Define to use S-Lang library for screen management])
210     mc_CHECK_SLANG_HEADER