|
1 |
| -dnl check for ncurses in user supplied path |
2 |
| -AC_DEFUN([mc_CHECK_NCURSES_BY_PATH], [ |
3 |
| -
|
4 |
| - ac_ncurses_inc_path=[$1] |
5 |
| - ac_ncurses_lib_path=[$2] |
6 |
| -
|
7 |
| - if test x"$ac_ncurses_inc_path" != x; then |
8 |
| - ac_ncurses_inc_path="-I"$ac_ncurses_inc_path |
9 |
| - fi |
10 |
| -
|
11 |
| - if test x"$ac_ncurses_lib_path" != x; then |
12 |
| - ac_ncurses_lib_path="-L"$ac_ncurses_lib_path |
13 |
| - fi |
14 |
| -
|
15 |
| - saved_CPPFLAGS="$CPPFLAGS" |
16 |
| - saved_LDFLAGS="$LDFLAGS" |
17 |
| - CPPFLAGS="$CPPFLAGS $ac_ncurses_inc_path" |
18 |
| - LDFLAGS="$LDFLAGS $ac_ncurses_lib_path" |
19 |
| -
|
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 |
| - ) |
50 |
| -
|
51 |
| - if test x"$found_ncurses" = x"yes"; then |
52 |
| - screen_type=ncurses |
53 |
| - screen_msg="NCurses" |
54 |
| -
|
55 |
| - AC_DEFINE(HAVE_NCURSES, 1, |
56 |
| - [Define to use ncurses library for screen management]) |
57 |
| -
|
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 |
64 |
| -]) |
65 |
| - |
66 | 1 | dnl
|
67 |
| -dnl Use the ncurses library. It can only be requested explicitly, |
| 2 | +dnl Use the NCurses library. It can only be requested explicitly, |
68 | 3 | dnl so just fail if anything goes wrong.
|
69 | 4 | 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= |
77 |
| -
|
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 |
| - ) |
86 |
| -
|
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 |
| - ) |
95 |
| -
|
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]) |
100 |
| -
|
101 |
| - LIBS="$MCLIBS" |
102 |
| - AC_SEARCH_LIBS([has_colors], [ncurses], [], |
103 |
| - [AC_MSG_ERROR([Cannot find ncurses library])]) |
104 |
| - AC_SEARCH_LIBS([stdscr], [tinfo], [], |
105 |
| - [AC_MSG_ERROR([Cannot find a library providing stdscr])]) |
106 |
| - MCLIBS="$LIBS" |
107 |
| -
|
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="$MCLIBS" |
114 |
| - AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [ncursesw_found=yes], |
115 |
| - [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])]) |
116 |
| - MCLIBS="$LIBS" |
117 |
| -
|
118 |
| - if test x"$ncursesw_found" = "x"; then |
119 |
| - LIBS="$MCLIBS" |
120 |
| - AC_SEARCH_LIBS([has_colors], [ncurses curses], [], |
121 |
| - [AC_MSG_ERROR([Cannot find ncurses library])]) |
122 |
| - MCLIBS="$LIBS" |
123 |
| - fi |
124 |
| - LIBS="$MCLIBS" |
125 |
| - AC_SEARCH_LIBS([stdscr], [tinfow tinfo], [], |
126 |
| - [AC_MSG_ERROR([Cannot find a library providing stdscr])]) |
127 |
| - MCLIBS="$LIBS" |
128 |
| -
|
129 |
| - dnl Check the header |
130 |
| - ncurses_h_found= |
131 |
| - AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h], |
132 |
| - [ncurses_h_found=yes; break]) |
133 |
| -
|
134 |
| - if test x"$ncurses_h_found" = "x"; then |
135 |
| - AC_MSG_ERROR([Cannot find ncurses header file]) |
136 |
| - fi |
137 |
| -
|
138 |
| - AC_CHECK_HEADERS([ncurses/term.h]) |
139 |
| -
|
140 |
| - screen_type=ncurses |
141 |
| - screen_msg="NCurses" |
142 |
| - AC_DEFINE(USE_NCURSES, 1, |
143 |
| - [Define to use ncurses for screen management]) |
144 |
| - fi |
145 |
| -
|
146 |
| - dnl check for ESCDELAY |
147 |
| - AC_CACHE_CHECK([for ESCDELAY variable], |
148 |
| - [mc_cv_ncurses_escdelay], |
149 |
| - [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ |
150 |
| - extern int ESCDELAY; |
151 |
| - ESCDELAY = 0; |
152 |
| - ]])], |
153 |
| - [mc_cv_ncurses_escdelay=yes], |
154 |
| - [mc_cv_ncurses_escdelay=no]) |
155 |
| - ]) |
156 |
| - if test x"$mc_cv_ncurses_escdelay" = xyes; then |
157 |
| - AC_DEFINE(HAVE_ESCDELAY, 1, |
158 |
| - [Define if ncurses has ESCDELAY variable]) |
159 |
| - fi |
160 |
| -
|
161 |
| - dnl check for resizeterm |
162 |
| - AC_CHECK_FUNCS(resizeterm) |
163 |
| - LIBS="$save_LIBS" |
164 |
| -]) |
165 |
| - |
| 5 | +dnl Search order: |
| 6 | +dnl 1) system path (adjust by --with-ncurses-libdir=<DIR>, --with-ncurses-includedir=<DIR>) |
| 7 | +dnl 2) pkg-config (adjust by NCURSES_LIBS, NCURSES_CFLAGS) |
166 | 8 | dnl
|
167 |
| -dnl Use the ncursesw library. It can only be requested explicitly, |
168 |
| -dnl so just fail if anything goes wrong. |
| 9 | +dnl Preference: |
| 10 | +dnl ncursesw > ncurses |
169 | 11 | dnl
|
170 |
| -dnl If ncursesw exports the ESCDELAY variable it should be set to 0 |
171 |
| -dnl or you'll have to press Esc three times to dismiss a dialog box. |
| 12 | +dnl Rules: |
| 13 | +dnl LIBS can be prepended |
| 14 | +dnl CFLAGS can be appended (compiler optimizations and directives look at the last options) |
| 15 | +dnl CPPFLAGS can be prepended (header search paths options look at the first path) |
172 | 16 | dnl
|
173 | 17 |
|
174 |
| -AC_DEFUN([mc_WITH_NCURSESW], [ |
175 |
| - dnl has_colors() is specific to ncurses, it's not in the old curses |
| 18 | +AC_DEFUN([mc_WITH_NCURSES], [ |
176 | 19 | save_LIBS="$LIBS"
|
177 |
| - LIBS= |
178 |
| - AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"], |
179 |
| - [AC_MSG_ERROR([Cannot find ncursesw library])]) |
180 |
| - AC_SEARCH_LIBS([stdscr], [tinfow ncursesw], [MCLIBS="$MCLIBS $LIBS"], |
181 |
| - [AC_MSG_ERROR([Cannot find a library providing stdscr])]) |
182 |
| -
|
183 |
| -
|
184 |
| - dnl Check the header |
185 |
| - ncurses_h_found= |
186 |
| - AC_CHECK_HEADERS([ncursesw/curses.h], |
187 |
| - [ncursesw_h_found=yes; break]) |
188 |
| -
|
189 |
| - if test x"$ncursesw_h_found" = "x"; then |
190 |
| - AC_MSG_ERROR([Cannot find ncursesw header file]) |
191 |
| - fi |
192 |
| -
|
193 |
| - screen_type=ncursesw |
194 |
| - screen_msg="NCursesw" |
195 |
| - AC_DEFINE(USE_NCURSESW, 1, |
196 |
| - [Define to use ncursesw for screen management]) |
197 |
| -
|
198 |
| - AC_CACHE_CHECK([for ESCDELAY variable], |
199 |
| - [mc_cv_ncursesw_escdelay], |
200 |
| - [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ |
201 |
| - extern int ESCDELAY; |
202 |
| - ESCDELAY = 0; |
203 |
| - ]])], |
204 |
| - [mc_cv_ncursesw_escdelay=yes], |
205 |
| - [mc_cv_ncursesw_escdelay=no]) |
206 |
| - ]) |
207 |
| - if test x"$mc_cv_ncursesw_escdelay" = xyes; then |
208 |
| - AC_DEFINE(HAVE_ESCDELAY, 1, |
209 |
| - [Define if ncursesw has ESCDELAY variable]) |
210 |
| - fi |
| 20 | + save_CFLAGS="$CFLAGS" |
| 21 | + save_CPPFLAGS="$CPPFLAGS" |
| 22 | + save_MCLIBS="$MCLIBS" |
| 23 | +
|
| 24 | + AC_MSG_CHECKING([for specific NCurses libdir]) |
| 25 | + AC_ARG_WITH([ncurses-libdir], |
| 26 | + [AS_HELP_STRING([--with-ncurses-libdir=@<:@DIR@:>@], [Path to NCurses library files])], |
| 27 | + [AS_IF([test ! -d "$withval"], [AC_MSG_ERROR([NCurses libdir path "$withval" not found])]) |
| 28 | + LIBS="-L$withval $LIBS" |
| 29 | + LDFLAGS="-L$withval $LIBS" |
| 30 | + MCLIBS="-L$withval $MCLIBS"], |
| 31 | + [with_ncurses_libdir=no]) |
| 32 | + AC_MSG_RESULT([$with_ncurses_libdir]) |
| 33 | +
|
| 34 | + AC_MSG_CHECKING([for specific NCurses includedir]) |
| 35 | + AC_ARG_WITH([ncurses-includedir], |
| 36 | + [AS_HELP_STRING([--with-ncurses-includedir=@<:@DIR@:>@], [Path to NCurses header files])], |
| 37 | + [AS_IF([test ! -d "$withval"], [AC_MSG_ERROR([NCurses includedir path "$withval" not found])]) |
| 38 | + CFLAGS="$save_CFLAGS -I$withval"], |
| 39 | + [with_ncurses_includedir=no]) |
| 40 | + AC_MSG_RESULT([$with_ncurses_includedir]) |
| 41 | +
|
| 42 | + dnl |
| 43 | + dnl Check ncurses library |
| 44 | + dnl |
| 45 | + dnl has_colors is specific to ncurses, it's not in the old curses |
| 46 | + dnl search in default linker path and LDFLAGS -L options |
| 47 | + AC_SEARCH_LIBS([has_colors], [ncursesw ncurses], |
| 48 | + [AS_CASE(["$ac_cv_search_has_colors"], |
| 49 | + ["-lncursesw"], [screen_msg="NCursesw"], |
| 50 | + ["-lncurses"], [screen_msg="NCurses"], |
| 51 | + ["none required"], [screen_msg="NCurses static"], dnl or system native? Who knows |
| 52 | + [AC_MSG_ERROR([Unknown ac_cv_search_has_colors option "$ac_cv_search_has_colors"])]) |
| 53 | + ], |
| 54 | + dnl 2. Library not found by system path, try pkg-config |
| 55 | + [PKG_CHECK_MODULES([NCURSES], [ncursesw], |
| 56 | + [ LIBS="$NCURSES_LIBS $save_LIBS" |
| 57 | + MCLIBS="$NCURSES_LIBS $save_MCLIBS" |
| 58 | + CFLAGS="$save_CFLAGS $NCURSES_CFLAGS" |
| 59 | + screen_msg="NCursesw" |
| 60 | + AC_CHECK_FUNC([has_colors], [], dnl Always validate pkg-config result |
| 61 | + [AC_MSG_ERROR([NCursesw pkg-config insufficient])]) |
| 62 | + ], |
| 63 | + [PKG_CHECK_MODULES([NCURSES], [ncurses], |
| 64 | + [ LIBS="$NCURSES_LIBS $save_LIBS" |
| 65 | + MCLIBS="$NCURSES_LIBS $save_MCLIBS" |
| 66 | + CFLAGS="$save_CFLAGS $NCURSES_CFLAGS" |
| 67 | + screen_msg="NCurses" |
| 68 | + AC_CHECK_FUNC([has_colors], [], dnl Always validate pkg-config result |
| 69 | + [AC_MSG_ERROR([NCurses pkg-config insufficient])]) |
| 70 | + ], |
| 71 | + [AC_MSG_ERROR([(N)Curses(w) library not found by system path neither pkg-config])]) |
| 72 | + ]) |
| 73 | + ]) |
| 74 | +
|
| 75 | + AC_SEARCH_LIBS([stdscr], [tinfow tinfo], [], |
| 76 | + dnl 2. Library not found by system path, try pkg-config |
| 77 | + [PKG_CHECK_MODULES([TINFOW], [tinfow], [], |
| 78 | + [AC_CHECK_FUNC([stdscr], [], dnl Always validate pkg-config result |
| 79 | + [AC_MSG_ERROR([Tinfow pkg-config insufficient])])], |
| 80 | + [PKG_CHECK_MODULES([TINFO], [tinfo], |
| 81 | + [AC_CHECK_FUNC([stdscr], [], dnl Always validate pkg-config result |
| 82 | + [AC_MSG_ERROR([Tinfo pkg-config insufficient])])], |
| 83 | + [AC_MSG_ERROR([Tinfo(w) library not found by system path neither pkg-config])]) |
| 84 | + ]) |
| 85 | + ]) |
| 86 | +
|
| 87 | + AC_CHECK_FUNC([addwstr], [], |
| 88 | + [AC_MSG_WARN([NCurses(w) library found without wide characters support])]) |
| 89 | +
|
| 90 | + dnl |
| 91 | + dnl Check ncurses header |
| 92 | + dnl |
| 93 | + dnl Set CPPFLAGS to avoid AC_CHECK_HEADERS warning "accepted by the compiler, rejected by the preprocessor!" |
| 94 | + CPPFLAGS="$CFLAGS" |
| 95 | + dnl first match wins, using break |
| 96 | + AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/curses.h ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h], |
| 97 | + [ncurses_h_found=yes; break], |
| 98 | + [ncurses_h_found=no]) |
| 99 | +
|
| 100 | + AS_IF([test x"$ncurses_h_found" != xyes], |
| 101 | + [AC_MSG_ERROR([NCurses(w) header file not found])]) |
| 102 | +
|
| 103 | + AC_CHECK_HEADERS([ncursesw/term.h ncurses/term.h term.h], |
| 104 | + [ncurses_term_h_found=yes; break], |
| 105 | + [ncurses_term_h_found=no]) |
| 106 | +
|
| 107 | + AS_IF([test x"$ncurses_term_h_found" != xyes], |
| 108 | + [AC_MSG_ERROR([NCurses(w) term.h header file not found])]) |
| 109 | +
|
| 110 | + dnl If ncurses exports the ESCDELAY variable it should be set to 0 |
| 111 | + dnl or you'll have to press Esc three times to dismiss a dialog box. |
| 112 | + AC_CACHE_CHECK([for ESCDELAY variable], [mc_cv_ncurses_escdelay], |
| 113 | + [AC_LINK_IFELSE( |
| 114 | + [AC_LANG_PROGRAM([[extern int ESCDELAY;]],[[ESCDELAY = 0;]])], |
| 115 | + [mc_cv_ncurses_escdelay=yes], [mc_cv_ncurses_escdelay=no]) |
| 116 | + ]) |
| 117 | +
|
| 118 | + AS_IF([test x"$mc_cv_ncurses_escdelay" = xyes], |
| 119 | + [AC_DEFINE([HAVE_ESCDELAY], [1], [Define if NCurses(w) has ESCDELAY variable])]) |
211 | 120 |
|
212 | 121 | AC_CHECK_FUNCS(resizeterm)
|
213 |
| - LIBS="$save_LIBS" |
| 122 | +
|
| 123 | + AC_DEFINE([HAVE_NCURSES], [1], [Define to use NCurses for screen management]) |
| 124 | + AC_DEFINE_UNQUOTED([NCURSES_LIB_DISPLAYNAME], ["$screen_msg"], [Define NCurses library display name]) |
214 | 125 | ])
|
0 commit comments