global.h Removed unneeded include of file "textconf.h"
[midnight-commander.git] / m4.include / mc-with-screen.m4
blobe1309755bbc6316a03c3d9922676f218e32c96b6
1 dnl
2 dnl Check if the system S-Lang library can be used.
3 dnl If not, and $1 is "strict", exit, otherwise fall back to mcslang.
4 dnl
5 AC_DEFUN([MC_CHECK_SLANG_BY_PATH], [
7     ac_slang_inc_path=[$1]
8     ac_slang_lib_path=[$2]
10     if test x"$ac_slang_inc_path" != x; then
11         ac_slang_inc_path="-I"$ac_slang_inc_path
12     fi
14     if test x"$ac_slang_lib_path" != x; then
15         ac_slang_lib_path="-L"$ac_slang_lib_path
16     fi
18     saved_CFLAGS="$CFLAGS"
19     saved_CPPFLAGS="$CPPFLAGS"
20     saved_LDFLAGS="$LDFLAGS"
22     CFLAGS="$CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
23     CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
25     dnl Check the header
26     AC_MSG_CHECKING([for slang.h])
27     AC_PREPROC_IFELSE(
28         [
29             AC_LANG_PROGRAM([#include <slang.h>],[return 0;])
30         ],
31         [
32             AC_MSG_RESULT(yes)
33             if test x"$ac_slang_inc_path" = x; then
34                 ac_slang_inc_path="-I/usr/include"
35             fi
36             if test x"$ac_slang_lib_path" = x; then
37                 ac_slang_lib_path="-L/usr/lib"
38             fi
39             found_slang=yes
40             AC_DEFINE(HAVE_SLANG_H, 1,[Define to use slang.h])
42         ],
43         [
44             AC_MSG_RESULT(no)
45             AC_MSG_CHECKING([for slang/slang.h])
46             AC_PREPROC_IFELSE(
47                 [
48                     AC_LANG_PROGRAM([#include <slang/slang.h>],[return 0;])
49                 ],
50                 [
51                     AC_MSG_RESULT(yes)
52                     if test x"$ac_slang_inc_path" = x; then
53                         ac_slang_inc_path="-I/usr/include"
54                     fi
55                     if test x"$ac_slang_lib_path" = x; then
56                         ac_slang_lib_path="-L/usr/lib"
57                     fi
58                     found_slang=yes
59                     AC_DEFINE(HAVE_SLANG_SLANG_H, 1,[Define to use slang.h])
60                 ],
61                 [
62                     AC_MSG_RESULT(no)
63                     found_slang=no
64                     error_msg_slang="Slang header not found"
65                 ]
66             )
67         ],
68     )
70     dnl Check if termcap is needed.
71     dnl This check must be done before anything is linked against S-Lang.
72     if test x"$found_slang" = x"yes"; then
73         CFLAGS="$saved_CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
74         LDFLAGS="$saved_LDFLAGS $ac_slang_lib_path"
75         CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
77         MC_SLANG_TERMCAP
78         if test x"$mc_cv_slang_termcap"  = x"yes"; then
79             ac_slang_lib_path="$ac_slang_lib_path -ltermcap"
80             CFLAGS="$saved_CFLAGS $ac_slang_inc_path $ac_slang_lib_path"
81             CPPFLAGS="$saved_CPPFLAGS $ac_slang_inc_path $ac_slang_lib_path"
82             LDFLAGS="$saved_LDFLAGS $ac_slang_lib_path"
83         fi
84     fi
85     dnl Check the library
86     if test x"$found_slang" = x"yes"; then
87         unset ac_cv_lib_slang_SLang_init_tty
88         AC_CHECK_LIB(
89             [slang],
90             [SLang_init_tty],
91             [:],
92             [
93                 found_slang=no
94                 error_msg_slang="S-lang library not found"
95             ]
96         )
97     fi
98     dnl check if S-Lang have version 2.0 or newer
99     if test x"$found_slang" = x"yes"; then
100         AC_MSG_CHECKING([for S-Lang version 2.0 or newer])
101         AC_TRY_RUN([
102 #ifdef HAVE_SLANG_SLANG_H
103 #include <slang/slang.h>
104 #else
105 #include <slang.h>
106 #endif
107 int main (void)
109 #if SLANG_VERSION >= 20000
110     return 0;
111 #else
112     return 1;
113 #endif
116             [mc_slang_is_valid_version=yes],
117             [mc_slang_is_valid_version=no],
118             [mc_slang_is_valid_version=no]
119         )
120         if test x$mc_slang_is_valid_version = xno; then
121             found_slang=no
122             error_msg_slang="S-Lang library version 2.0 or newer not found"
123         fi
124         AC_MSG_RESULT($mc_slang_is_valid_version)
125     fi
127     dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
128     if test x"$found_slang" = x"yes"; then
129         unset ac_cv_lib_slang_SLsmg_write_nwchars
130         AC_CHECK_LIB(
131             [slang],
132             [SLsmg_write_nwchars],
133             [
134                 found_slang=no
135                 error_msg_slang="Rejecting S-Lang with UTF-8 support, it's not fully supported yet"
136             ],
137             [:]
138         )
139     fi
141     if test x"$found_slang" = x"yes"; then
142         screen_type=slang
143         screen_msg="S-Lang library (installed on the system)"
145         AC_DEFINE(HAVE_SLANG, 1,
146             [Define to use S-Lang library for screen management])
148         MCLIBS="$MCLIBS $ac_slang_lib_path -lslang"
149     fi
150     CFLAGS="$saved_CFLAGS"
151     CPPFLAGS="$saved_CPPFLAGS"
152     LDFLAGS="$saved_LDFLAGS"
156 dnl Use the slang library.
158 AC_DEFUN([MC_WITH_SLANG], [
159     with_screen=slang
160     found_slang=yes
161     error_msg_slang=""
163     AC_ARG_WITH([slang-includes],
164         AC_HELP_STRING([--with-slang-includes=@<:@DIR@:>@],
165             [set path to SLANG includes @<:@default=/usr/include@:>@; may sense only if --with-screen=slang]
166         ),
167         [ac_slang_inc_path="$withval"],
168         [ac_slang_inc_path=""]
169     )
171     AC_ARG_WITH([slang-libs],
172         AC_HELP_STRING([--with-slang-libs=@<:@DIR@:>@],
173             [set path to SLANG library @<:@default=/usr/lib@:>@; may sense only if --with-screen=slang]
174         ),
175         [ac_slang_lib_path="$withval"],
176         [ac_slang_lib_path=""]
177     )
178     echo 'checking SLANG-headers in default place ...'
179     MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
180     if test x"$found_slang" = "xno"; then
181         ac_slang_inc_path="/usr/include"
182         ac_slang_lib_path="/usr/lib"
184         echo 'checking SLANG-headers in /usr ...'
185         MC_CHECK_SLANG_BY_PATH([$ac_slang_inc_path],[$ac_slang_lib_path])
186         if test x"$found_slang" = "xno"; then
187             ac_slang_inc_path="/usr/local/include"
188             ac_slang_lib_path="/usr/local/lib"
190             echo 'checking SLANG-headers in /usr/local ...'
191             MC_CHECK_SLANG_BY_PATH( $ac_slang_inc_path , $ac_slang_lib_path )
192             if test x"$found_slang" = "xno"; then
193                 AC_MSG_ERROR([$error_msg_slang])
194             fi
195         fi
196     fi
201 dnl Use the ncurses library.  It can only be requested explicitly,
202 dnl so just fail if anything goes wrong.
204 dnl If ncurses exports the ESCDELAY variable it should be set to 0
205 dnl or you'll have to press Esc three times to dismiss a dialog box.
207 AC_DEFUN([MC_WITH_NCURSES], [
208     dnl has_colors() is specific to ncurses, it's not in the old curses
209     save_LIBS="$LIBS"
210     ncursesw_found=
211     LIBS=
212     AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes],
213                    [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
215     if test x"$ncursesw_found" = "x"; then
216     LIBS=
217     AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
218                    [AC_MSG_ERROR([Cannot find ncurses library])])
219     fi
221     dnl Check the header
222     ncurses_h_found=
223     AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],
224                      [ncurses_h_found=yes; break])
226     if test x"$ncurses_h_found" = "x"; then
227         AC_MSG_ERROR([Cannot find ncurses header file])
228     fi
230     screen_type=ncurses
231     screen_msg="ncurses library"
232     AC_DEFINE(USE_NCURSES, 1,
233               [Define to use ncurses for screen management])
235     AC_CACHE_CHECK([for ESCDELAY variable],
236                    [mc_cv_ncurses_escdelay],
237                    [AC_TRY_LINK([], [
238                         extern int ESCDELAY;
239                         ESCDELAY = 0;
240                         ],
241                         [mc_cv_ncurses_escdelay=yes],
242                         [mc_cv_ncurses_escdelay=no])
243     ])
244     if test x"$mc_cv_ncurses_escdelay" = xyes; then
245         AC_DEFINE(HAVE_ESCDELAY, 1,
246                   [Define if ncurses has ESCDELAY variable])
247     fi
249     AC_CHECK_FUNCS(resizeterm)
250     LIBS="$save_LIBS"
254 dnl Use the ncursesw library.  It can only be requested explicitly,
255 dnl so just fail if anything goes wrong.
257 dnl If ncursesw exports the ESCDELAY variable it should be set to 0
258 dnl or you'll have to press Esc three times to dismiss a dialog box.
261 AC_DEFUN([MC_WITH_NCURSESW], [
262     dnl has_colors() is specific to ncurses, it's not in the old curses
263     save_LIBS="$LIBS"
264     LIBS=
265     AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
266                    [AC_MSG_ERROR([Cannot find ncursesw library])])
268     dnl Check the header
269     ncurses_h_found=
270     AC_CHECK_HEADERS([ncursesw/curses.h],
271                      [ncursesw_h_found=yes; break])
273     if test  x"$ncursesw_h_found" = "x"; then
274         AC_MSG_ERROR([Cannot find ncursesw header file])
275     fi
277     screen_type=ncursesw
278     screen_msg="ncursesw library"
279     AC_DEFINE(USE_NCURSESW, 1,
280               [Define to use ncursesw for screen management])
282     AC_CACHE_CHECK([for ESCDELAY variable],
283                    [mc_cv_ncursesw_escdelay],
284                    [AC_TRY_LINK([], [
285                         extern int ESCDELAY;
286                         ESCDELAY = 0;
287                         ],
288                         [mc_cv_ncursesw_escdelay=yes],
289                         [mc_cv_ncursesw_escdelay=no])
290     ])
291     if test x"$mc_cv_ncursesw_escdelay" = xyes; then
292         AC_DEFINE(HAVE_ESCDELAY, 1,
293                   [Define if ncursesw has ESCDELAY variable])
294     fi
296     AC_CHECK_FUNCS(resizeterm)
297     LIBS="$save_LIBS"