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 | | |
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= |
102 | | AC_SEARCH_LIBS([has_colors], [ncurses], [MCLIBS="$MCLIBS $LIBS"], |
103 | | [AC_MSG_ERROR([Cannot find ncurses library])]) |
104 | | |
105 | | screen_type=ncurses |
106 | | screen_msg="NCurses" |
107 | | AC_DEFINE(USE_NCURSES, 1, |
108 | | [Define to use ncurses for screen management]) |
109 | | else |
110 | | LIBS= |
111 | | AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes], |
112 | | [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])]) |
113 | | |
114 | | if test x"$ncursesw_found" = "x"; then |
115 | | LIBS= |
116 | | AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"], |
117 | | [AC_MSG_ERROR([Cannot find ncurses library])]) |
118 | | fi |
119 | | |
120 | | dnl Check the header |
121 | | ncurses_h_found= |
122 | | AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h], |
123 | | [ncurses_h_found=yes; break]) |
124 | | |
125 | | if test x"$ncurses_h_found" = "x"; then |
126 | | AC_MSG_ERROR([Cannot find ncurses header file]) |
127 | | fi |
128 | | |
129 | | screen_type=ncurses |
130 | | screen_msg="NCurses" |
131 | | AC_DEFINE(USE_NCURSES, 1, |
132 | | [Define to use ncurses for screen management]) |
133 | | fi |
134 | | |
135 | | dnl check for ESCDELAY |
136 | | AC_CACHE_CHECK([for ESCDELAY variable], |
137 | | [mc_cv_ncurses_escdelay], |
138 | | [AC_TRY_LINK([], [ |
139 | | extern int ESCDELAY; |
140 | | ESCDELAY = 0; |
141 | | ], |
142 | | [mc_cv_ncurses_escdelay=yes], |
143 | | [mc_cv_ncurses_escdelay=no]) |
144 | | ]) |
145 | | if test x"$mc_cv_ncurses_escdelay" = xyes; then |
146 | | AC_DEFINE(HAVE_ESCDELAY, 1, |
147 | | [Define if ncurses has ESCDELAY variable]) |
148 | | fi |
149 | | |
150 | | dnl check for resizeterm |
151 | | AC_CHECK_FUNCS(resizeterm) |
152 | | LIBS="$save_LIBS" |
153 | | ]) |
154 | | |
| 9 | dnl Preference: |
| 10 | dnl ncursesw > ncurses |
166 | | LIBS= |
167 | | AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"], |
168 | | [AC_MSG_ERROR([Cannot find ncursesw library])]) |
169 | | |
170 | | dnl Check the header |
171 | | ncurses_h_found= |
172 | | AC_CHECK_HEADERS([ncursesw/curses.h], |
173 | | [ncursesw_h_found=yes; break]) |
174 | | |
175 | | if test x"$ncursesw_h_found" = "x"; then |
176 | | AC_MSG_ERROR([Cannot find ncursesw header file]) |
177 | | fi |
178 | | |
179 | | screen_type=ncursesw |
180 | | screen_msg="NCursesw" |
181 | | AC_DEFINE(USE_NCURSESW, 1, |
182 | | [Define to use ncursesw for screen management]) |
183 | | |
184 | | AC_CACHE_CHECK([for ESCDELAY variable], |
185 | | [mc_cv_ncursesw_escdelay], |
186 | | [AC_TRY_LINK([], [ |
187 | | extern int ESCDELAY; |
188 | | ESCDELAY = 0; |
189 | | ], |
190 | | [mc_cv_ncursesw_escdelay=yes], |
191 | | [mc_cv_ncursesw_escdelay=no]) |
192 | | ]) |
193 | | if test x"$mc_cv_ncursesw_escdelay" = xyes; then |
194 | | AC_DEFINE(HAVE_ESCDELAY, 1, |
195 | | [Define if ncursesw has ESCDELAY variable]) |
196 | | fi |
| 19 | save_CFLAGS="$CFLAGS" |
| 20 | save_CPPFLAGS="$CPPFLAGS" |
| 21 | save_MCLIBS="$MCLIBS" |
| 22 | |
| 23 | AC_MSG_CHECKING([for specific ncurses-libdir]) |
| 24 | AC_ARG_WITH([ncurses-libdir], |
| 25 | [AS_HELP_STRING([--with-ncurses-libdir=@<:@DIR@:>@], [Path to ncurses library files])], |
| 26 | [AS_IF([test ! -d "$withval"], [AC_MSG_ERROR([ncurses-libdir path "$withval" not found])]) |
| 27 | LIBS="-L$withval $LIBS" |
| 28 | LDFLAGS="-L$withval $LIBS" |
| 29 | MCLIBS="-L$withval $MCLIBS"], |
| 30 | [with_ncurses_libdir=no]) |
| 31 | AC_MSG_RESULT([$with_ncurses_libdir]) |
| 32 | |
| 33 | AC_MSG_CHECKING([for specific ncurses-includedir]) |
| 34 | AC_ARG_WITH([ncurses-includedir], |
| 35 | [AS_HELP_STRING([--with-screen-includedir=@<:@DIR@:>@], [Path to screen header files])], |
| 36 | [AS_IF([test ! -d "$withval"], [AC_MSG_ERROR([ncurses-includedir path "$withval" not found])]) |
| 37 | CFLAGS="$save_CFLAGS -I$withval"], |
| 38 | [with_ncurses_includedir=no]) |
| 39 | AC_MSG_RESULT([$with_ncurses_includedir]) |
| 40 | |
| 41 | dnl |
| 42 | dnl Check ncurses library |
| 43 | dnl |
| 44 | dnl has_colors is specific to ncurses, it's not in the old curses |
| 45 | dnl search in default linker path and LDFLAGS -L options |
| 46 | AC_SEARCH_LIBS([has_colors], [ncursesw ncurses], |
| 47 | [AS_CASE(["$ac_cv_search_has_colors"], |
| 48 | ["-lncursesw"], [screen_msg="NCursesw"], |
| 49 | ["-lncurses"], [screen_msg="NCurses"], |
| 50 | ["none required"], [screen_msg="NCurses static"], dnl or system native? Who knows |
| 51 | [AC_MSG_ERROR([Unknown ac_cv_search_has_colors option "$ac_cv_search_has_colors"])])], |
| 52 | dnl 2) Library not found by system path, try pkg-config |
| 53 | [PKG_CHECK_MODULES([NCURSES], [ncursesw], |
| 54 | [LIBS="$NCURSES_LIBS $save_LIBS" |
| 55 | MCLIBS="$NCURSES_LIBS $save_MCLIBS" |
| 56 | CFLAGS="$save_CFLAGS $NCURSES_CFLAGS" |
| 57 | screen_msg="Ncursesw" |
| 58 | AC_CHECK_FUNC([has_colors], [], dnl Always validate pkg-config result |
| 59 | [AC_MSG_ERROR([Ncursesw pkg-config insufficient])])], |
| 60 | [PKG_CHECK_MODULES([NCURSES], [ncurses], |
| 61 | [LIBS="$NCURSES_LIBS $save_LIBS" |
| 62 | MCLIBS="$NCURSES_LIBS $save_MCLIBS" |
| 63 | CFLAGS="$save_CFLAGS $NCURSES_CFLAGS" |
| 64 | screen_msg="Ncurses" |
| 65 | AC_CHECK_FUNC([has_colors], [], dnl Always validate pkg-config result |
| 66 | [AC_MSG_ERROR([Ncurses pkg-config insufficient])])], |
| 67 | [AC_MSG_ERROR([Ncurses(w) library not found by system path neither pkg-config])])])]) |
| 68 | |
| 69 | AC_CHECK_FUNC([addwstr], [], |
| 70 | [AC_MSG_WARN([Ncurses(w) library found without wide characters support])]) |
| 71 | |
| 72 | dnl |
| 73 | dnl Check ncurses header |
| 74 | dnl |
| 75 | dnl Set CPPFLAGS to avoid AC_CHECK_HEADERS warning "accepted by the compiler, rejected by the preprocessor!" |
| 76 | CPPFLAGS="$CFLAGS" |
| 77 | dnl first match wins, using break |
| 78 | AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/curses.h ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h], |
| 79 | [ncurses_h_found=yes; break], |
| 80 | [ncurses_h_found=no]) |
| 81 | |
| 82 | AS_IF([test x"$ncurses_h_found" != xyes], |
| 83 | [AC_MSG_ERROR([Ncurses(w) header file not found])]) |
| 84 | |
| 85 | AC_CHECK_HEADERS([ncursesw/term.h ncurses/term.h term.h], |
| 86 | [ncurses_term_h_found=yes; break], |
| 87 | [ncurses_term_h_found=no]) |
| 88 | |
| 89 | AS_IF([test x"$ncurses_term_h_found" != xyes], |
| 90 | [AC_MSG_ERROR([Ncurses(w) term.h header file not found])]) |
| 91 | |
| 92 | dnl If ncurses exports the ESCDELAY variable it should be set to 0 |
| 93 | dnl or you'll have to press Esc three times to dismiss a dialog box. |
| 94 | AC_CACHE_CHECK([for ESCDELAY variable], [mc_cv_ncurses_escdelay], |
| 95 | [AC_LINK_IFELSE( |
| 96 | [AC_LANG_PROGRAM([[extern int ESCDELAY;]],[[ESCDELAY = 0;]])], |
| 97 | [mc_cv_ncurses_escdelay=yes], [mc_cv_ncurses_escdelay=no])]) |
| 98 | |
| 99 | AS_IF([test x"$mc_cv_ncurses_escdelay" = xyes], |
| 100 | [AC_DEFINE([HAVE_ESCDELAY], [1], [Define if ncurses(w) has ESCDELAY variable])]) |