(regex_command_for): move load of extension file to separate function.
[midnight-commander.git] / m4.include / mc-with-screen-ncurses.m4
blob80d8478c9584685bef8f2280e263bfe128c6cb3a
1 dnl check for ncurses in user supplied path
2 AC_DEFUN([mc_CHECK_NCURSES_BY_PATH], [
4     ac_ncurses_inc_path=[$1]
5     ac_ncurses_lib_path=[$2]
7     if test x"$ac_ncurses_inc_path" != x; then
8         ac_ncurses_inc_path="-I"$ac_ncurses_inc_path
9     fi
11     if test x"$ac_ncurses_lib_path" != x; then
12         ac_ncurses_lib_path="-L"$ac_ncurses_lib_path
13     fi
15     saved_CPPFLAGS="$CPPFLAGS"
16     saved_LDFLAGS="$LDFLAGS"
17     CPPFLAGS="$CPPFLAGS $ac_ncurses_inc_path"
18     LDFLAGS="$LDFLAGS $ac_ncurses_lib_path"
20     dnl Check for the headers
21     dnl Both headers should be in the same directory
22     dnl AIX term.h is unusable for mc
23     AC_MSG_CHECKING([for ncurses/ncurses.h and ncurses/term.h])
24     AC_PREPROC_IFELSE(
25         [
26             AC_LANG_PROGRAM([[#include <ncurses/ncurses.h>
27                               #include <ncurses/term.h>
28                             ]],[[return 0;]])
29         ],
30         [
31             AC_MSG_RESULT(yes)
32             if test x"$ac_ncurses_inc_path" = x; then
33                 ac_ncurses_inc_path="-I/usr/include"
34             fi
35             if test x"$ac_ncurses_lib_path" = x; then
36               ac_ncurses_lib_path="-L/usr/lib"
37             fi
38             found_ncurses=yes
39             AC_DEFINE(HAVE_NCURSES_NCURSES_H, 1,
40                       [Define to 1 if you have the <ncurses/ncurses.h> header file.])
41             AC_DEFINE(HAVE_NCURSES_TERM_H, 1,
42                       [Define to 1 if you have the <ncurses/term.h> header file.])
43         ],
44         [
45             AC_MSG_RESULT(no)
46             found_ncurses=no
47             error_msg_ncurses="ncurses header not found"
48         ],
49     )
51     if test x"$found_ncurses" = x"yes"; then
52         screen_type=ncurses
53         screen_msg="NCurses"
55         AC_DEFINE(HAVE_NCURSES, 1,
56                   [Define to use ncurses library for screen management])
58         MCLIBS="$MCLIBS $ac_ncurses_lib_path"
59     else
60         CPPFLAGS="$saved_CPPFLAGS"
61         LDFLAGS="$saved_LDPFLAGS"
62         AC_MSG_ERROR([$error_msg_ncurses])
63     fi
66 dnl
67 dnl Use the ncurses library.  It can only be requested explicitly,
68 dnl so just fail if anything goes wrong.
69 dnl
70 dnl If ncurses exports the ESCDELAY variable it should be set to 0
71 dnl or you'll have to press Esc three times to dismiss a dialog box.
72 dnl
73 AC_DEFUN([mc_WITH_NCURSES], [
74     dnl has_colors() is specific to ncurses, it's not in the old curses
75     save_LIBS="$LIBS"
76     ncursesw_found=
78     dnl get the user supplied include path
79     AC_ARG_WITH([ncurses-includes],
80         AS_HELP_STRING([--with-ncurses-includes=@<:@DIR@:>@],
81             [set path to ncurses includes @<:@default=/usr/include@:>@; make sense only if --with-screen=ncurses; for /usr/local/include/ncurses specify /usr/local/include]
82         ),
83         [ac_ncurses_inc_path="$withval"],
84         [ac_ncurses_inc_path=""]
85     )
87     dnl get the user supplied lib path
88     AC_ARG_WITH([ncurses-libs],
89         AS_HELP_STRING([--with-ncurses-libs=@<:@DIR@:>@],
90             [set path to ncurses library @<:@default=/usr/lib@:>@; make sense only if --with-screen=ncurses]
91         ),
92         [ac_ncurses_lib_path="$withval"],
93         [ac_ncurses_lib_path=""]
94     )
96     dnl we need at least the inc path, the lib may be in a std location
97     if test x"$ac_ncurses_inc_path" != x; then
98         dnl check the user supplied location
99         mc_CHECK_NCURSES_BY_PATH([$ac_ncurses_inc_path],[$ac_ncurses_lib_path])
101         LIBS=
102         AC_SEARCH_LIBS([has_colors], [ncurses], [MCLIBS="$MCLIBS $LIBS"], 
103                        [AC_MSG_ERROR([Cannot find ncurses library])])
104         AC_SEARCH_LIBS([stdscr], [tinfo ncurses], [MCLIBS="$MCLIBS $LIBS"],
105                        [AC_MSG_ERROR([Cannot find a library providing stdscr])])
108         screen_type=ncurses
109         screen_msg="NCurses"
110         AC_DEFINE(USE_NCURSES, 1, 
111                   [Define to use ncurses for screen management])
112     else
113         LIBS=
114         AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes],
115                        [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
117         AC_SEARCH_LIBS([stdscr], [tinfow tinfo ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
118                        [AC_MSG_ERROR([Cannot find a library providing stdscr])])
120         if test x"$ncursesw_found" = "x"; then
121             LIBS=
122             AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"], 
123                            [AC_MSG_ERROR([Cannot find ncurses library])])
124             AC_SEARCH_LIBS([stdscr], [tinfo ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
125                            [AC_MSG_ERROR([Cannot find a library providing stdscr])])
126         fi
128         dnl Check the header
129         ncurses_h_found=
130         AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h], 
131                          [ncurses_h_found=yes; break])
133         if test x"$ncurses_h_found" = "x"; then
134             AC_MSG_ERROR([Cannot find ncurses header file])
135         fi
137         screen_type=ncurses
138         screen_msg="NCurses"
139         AC_DEFINE(USE_NCURSES, 1, 
140                   [Define to use ncurses for screen management])
141     fi
143     dnl check for ESCDELAY
144     AC_CACHE_CHECK([for ESCDELAY variable],
145                    [mc_cv_ncurses_escdelay],
146                    [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
147                         extern int ESCDELAY;
148                         ESCDELAY = 0;
149                         ]])],
150                         [mc_cv_ncurses_escdelay=yes],
151                         [mc_cv_ncurses_escdelay=no])
152     ])
153     if test x"$mc_cv_ncurses_escdelay" = xyes; then
154         AC_DEFINE(HAVE_ESCDELAY, 1, 
155                   [Define if ncurses has ESCDELAY variable])
156     fi
158     dnl check for resizeterm
159     AC_CHECK_FUNCS(resizeterm)
160     LIBS="$save_LIBS"
164 dnl Use the ncursesw library.  It can only be requested explicitly,
165 dnl so just fail if anything goes wrong.
167 dnl If ncursesw exports the ESCDELAY variable it should be set to 0
168 dnl or you'll have to press Esc three times to dismiss a dialog box.
171 AC_DEFUN([mc_WITH_NCURSESW], [
172     dnl has_colors() is specific to ncurses, it's not in the old curses
173     save_LIBS="$LIBS"
174     LIBS=
175     AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
176                    [AC_MSG_ERROR([Cannot find ncursesw library])])
177     AC_SEARCH_LIBS([stdscr], [tinfow ncursesw], [MCLIBS="$MCLIBS $LIBS"],
178            [AC_MSG_ERROR([Cannot find a library providing stdscr])])
181     dnl Check the header
182     ncurses_h_found=
183     AC_CHECK_HEADERS([ncursesw/curses.h],
184                      [ncursesw_h_found=yes; break])
186     if test  x"$ncursesw_h_found" = "x"; then
187         AC_MSG_ERROR([Cannot find ncursesw header file])
188     fi
190     screen_type=ncursesw
191     screen_msg="NCursesw"
192     AC_DEFINE(USE_NCURSESW, 1,
193               [Define to use ncursesw for screen management])
195     AC_CACHE_CHECK([for ESCDELAY variable],
196                    [mc_cv_ncursesw_escdelay],
197                    [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
198                         extern int ESCDELAY;
199                         ESCDELAY = 0;
200                         ]])],
201                         [mc_cv_ncursesw_escdelay=yes],
202                         [mc_cv_ncursesw_escdelay=no])
203     ])
204     if test x"$mc_cv_ncursesw_escdelay" = xyes; then
205         AC_DEFINE(HAVE_ESCDELAY, 1,
206                   [Define if ncursesw has ESCDELAY variable])
207     fi
209     AC_CHECK_FUNCS(resizeterm)
210     LIBS="$save_LIBS"