1 dnl Curses detection: Munged from Midnight Commander's configure.in
2 dnl
3 dnl What it does:
4 dnl =============
5 dnl
6 dnl - Determine which version of curses is installed on your system
7 dnl and set the -I/-L/-l compiler entries and add a few preprocessor
8 dnl symbols
9 dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
10 dnl @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
11 dnl Makefile.in's
12 dnl - Modify the following configure variables (these are the only
13 dnl curses.m4 variables you can access from within configure.in)
14 dnl CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
15 dnl an ncurses.h that's been renamed to curses.h
16 dnl is found.
17 dnl CURSES_LIBS - sets -L and -l's appropriately
18 dnl CFLAGS - if --with-sco, add -D_SVID3
19 dnl has_curses - exports result of tests to rest of configure
20 dnl
21 dnl Usage:
22 dnl ======
23 dnl 1) Add lines indicated below to acconfig.h
24 dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
25 dnl 3) Instead of #include <curses.h> you should use the following to
26 dnl properly locate ncurses or curses header file
27 dnl
28 dnl #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
29 dnl #include <ncurses.h>
30 dnl #else
31 dnl #include <curses.h>
32 dnl #endif
33 dnl
34 dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
35 dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
36 dnl
37 dnl Notes with automake:
38 dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
39 dnl configure.in
40 dnl - your Makefile.am can look something like this
41 dnl -----------------------------------------------
42 dnl INCLUDES= blah blah blah $(CURSES_INCLUDEDIR)
43 dnl if HAS_CURSES
44 dnl CURSES_TARGETS=name_of_curses_prog
45 dnl endif
46 dnl bin_PROGRAMS = other_programs $(CURSES_TARGETS)
47 dnl other_programs_SOURCES = blah blah blah
48 dnl name_of_curses_prog_SOURCES = blah blah blah
49 dnl other_programs_LDADD = blah
50 dnl name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
51 dnl -----------------------------------------------
52 dnl
53 dnl
54 dnl The following lines should be added to acconfig.h:
55 dnl ==================================================
56 dnl
57 dnl /*=== Curses version detection defines ===*/
58 dnl /* Found some version of curses that we're going to use */
59 dnl #undef HAS_CURSES
60 dnl
61 dnl /* Use SunOS SysV curses? */
62 dnl #undef USE_SUNOS_CURSES
63 dnl
64 dnl /* Use old BSD curses - not used right now */
65 dnl #undef USE_BSD_CURSES
66 dnl
67 dnl /* Use SystemV curses? */
68 dnl #undef USE_SYSV_CURSES
69 dnl
70 dnl /* Use Ncurses? */
71 dnl #undef USE_NCURSES
72 dnl
73 dnl /* If you Curses does not have color define this one */
74 dnl #undef NO_COLOR_CURSES
75 dnl
76 dnl /* Define if you want to turn on SCO-specific code */
77 dnl #undef SCO_FLAVOR
78 dnl
79 dnl /* Set to reflect version of ncurses *
80 dnl * 0 = version 1.*
81 dnl * 1 = version 1.9.9g
82 dnl * 2 = version 4.0/4.1 */
83 dnl #undef NCURSES_970530
84 dnl
85 dnl /*=== End new stuff for acconfig.h ===*/
86 dnl
87
88
89 AC_DEFUN([AC_CHECK_CURSES],[
90 search_ncurses=true
91 screen_manager=""
92 has_curses=false
93
94 CFLAGS=${CFLAGS--O}
95
96 AC_SUBST(CURSES_LIBS)
97 AC_SUBST(CURSES_INCLUDEDIR)
98
99 AC_ARG_WITH(sco,
100 [ --with-sco Use this to turn on SCO-specific code],[
101 if test x$withval = xyes; then
102 AC_DEFINE(SCO_FLAVOR)
103 CFLAGS="$CFLAGS -D_SVID3"
104 fi
105 ])
106
107 AC_ARG_WITH(sunos-curses,
108 [ --with-sunos-curses Used to force SunOS 4.x curses],[
109 if test x$withval = xyes; then
110 AC_USE_SUNOS_CURSES
111 fi
112 ])
113
114 AC_ARG_WITH(osf1-curses,
115 [ --with-osf1-curses Used to force OSF/1 curses],[
116 if test x$withval = xyes; then
117 AC_USE_OSF1_CURSES
118 fi
119 ])
120
121 AC_ARG_WITH(vcurses,
122 [ --with-vcurses[=incdir] Used to force SysV curses],
123 if test x$withval != xyes; then
124 CURSES_INCLUDEDIR="-I$withval"
125 fi
126 AC_USE_SYSV_CURSES
127 )
128
129 AC_ARG_WITH(ncurses,
130 [ --with-ncurses[=dir] Compile with ncurses/locate base dir],
131 if test x$withval = xno ; then
132 search_ncurses=false
133 elif test x$withval != xyes ; then
134 CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
135 CURSES_INCLUDEDIR="-I$withval/include"
136 search_ncurses=false
137 screen_manager="ncurses"
138 AC_DEFINE(USE_NCURSES)
139 AC_DEFINE(HAS_CURSES)
140 has_curses=true
141 fi
142 )
143
144 if $search_ncurses
145 then
146 AC_SEARCH_NCURSES()
147 fi
148
149
150 ])
151
152
153 AC_DEFUN([AC_USE_SUNOS_CURSES], [
154 search_ncurses=false
155 screen_manager="SunOS 4.x /usr/5include curses"
156 AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
157 AC_DEFINE(USE_SUNOS_CURSES)
158 AC_DEFINE(HAS_CURSES)
159 has_curses=true
160 AC_DEFINE(NO_COLOR_CURSES)
161 AC_DEFINE(USE_SYSV_CURSES)
162 CURSES_INCLUDEDIR="-I/usr/5include"
163 CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
164 AC_MSG_RESULT(Please note that some screen refreshs may fail)
165 ])
166
167 AC_DEFUN([AC_USE_OSF1_CURSES], [
168 AC_MSG_RESULT(Using OSF1 curses)
169 search_ncurses=false
170 screen_manager="OSF1 curses"
171 AC_DEFINE(HAS_CURSES)
172 has_curses=true
173 AC_DEFINE(NO_COLOR_CURSES)
174 AC_DEFINE(USE_SYSV_CURSES)
175 CURSES_LIBS="-lcurses"
176 ])
177
178 AC_DEFUN([AC_USE_SYSV_CURSES], [
179 AC_MSG_RESULT(Using SysV curses)
180 AC_DEFINE(HAS_CURSES)
181 has_curses=true
182 AC_DEFINE(USE_SYSV_CURSES)
183 search_ncurses=false
184 screen_manager="SysV/curses"
185 CURSES_LIBS="-lcurses"
186 ])
187
188 dnl AC_ARG_WITH(bsd-curses,
189 dnl [--with-bsd-curses Used to compile with bsd curses, not very fancy],
190 dnl search_ncurses=false
191 dnl screen_manager="Ultrix/cursesX"
192 dnl if test $system = ULTRIX
193 dnl then
194 dnl THIS_CURSES=cursesX
195 dnl else
196 dnl THIS_CURSES=curses
197 dnl fi
198 dnl
199 dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap"
200 dnl AC_DEFINE(HAS_CURSES)
201 dnl has_curses=true
202 dnl AC_DEFINE(USE_BSD_CURSES)
203 dnl AC_MSG_RESULT(Please note that some screen refreshs may fail)
204 dnl AC_MSG_WARN(Use of the bsdcurses extension has some)
205 dnl AC_MSG_WARN(display/input problems.)
206 dnl AC_MSG_WARN(Reconsider using xcurses)
207 dnl)
208
209
210 dnl
211 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
212 dnl
213 AC_DEFUN([AC_NCURSES], [
214 if $search_ncurses
215 then
216 if test -f $1/$2
217 then
218 AC_MSG_RESULT(Found ncurses on $1/$2)
219 CURSES_LIBS="$3"
220 CURSES_INCLUDEDIR="$4"
221 search_ncurses=false
222 screen_manager=$5
223 AC_DEFINE(HAS_CURSES)
224 has_curses=true
225 AC_DEFINE(USE_NCURSES)
226 fi
227 fi
228 ])
229
230 AC_DEFUN([AC_SEARCH_NCURSES], [
231 AC_CHECKING("location of ncurses.h file")
232
233 AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
234 AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
235 AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
236 AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
237
238 AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
239
240 AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
241
242 dnl
243 dnl We couldn't find ncurses, try SysV curses
244 dnl
245 if $search_ncurses
246 then
247 AC_EGREP_HEADER(init_color, /usr/include/curses.h,
248 AC_USE_SYSV_CURSES)
249 AC_EGREP_CPP(USE_NCURSES,[
250 #include <curses.h>
251 #ifdef __NCURSES_H
252 #undef USE_NCURSES
253 USE_NCURSES
254 #endif
255 ],[
256 CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
257 AC_DEFINE(HAS_CURSES)
258 has_curses=true
259 AC_DEFINE(USE_NCURSES)
260 search_ncurses=false
261 screen_manager="ncurses installed as curses"
262 ])
263 fi
264
265 dnl
266 dnl Try SunOS 4.x /usr/5{lib,include} ncurses
267 dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
268 dnl should be replaced by a more fine grained selection routine
269 dnl
270 if $search_ncurses
271 then
272 if test -f /usr/5include/curses.h
273 then
274 AC_USE_SUNOS_CURSES
275 fi
276 else
277 # check for ncurses version, to properly ifdef mouse-fix
278 AC_MSG_CHECKING(for ncurses version)
279 ncurses_version=unknown
280 cat > conftest.$ac_ext <<EOF
281 [#]line __oline__ "configure"
282 #include "confdefs.h"
283 #ifdef RENAMED_NCURSES
284 #include <curses.h>
285 #else
286 #include <ncurses.h>
287 #endif
288 #undef VERSION
289 VERSION:NCURSES_VERSION
290 EOF
291 if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
292 egrep "VERSION:" >conftest.out 2>&1; then
293 changequote(,)dnl
294 ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
295 changequote([,])dnl
296 fi
297 rm -rf conftest*
298 AC_MSG_RESULT($ncurses_version)
299 case "$ncurses_version" in
300 changequote(,)dnl
301 4.[01])
302 changequote([,])dnl
303 AC_DEFINE(NCURSES_970530,2)
304 ;;
305 1.9.9g)
306 AC_DEFINE(NCURSES_970530,1)
307 ;;
308 1*)
309 AC_DEFINE(NCURSES_970530,0)
310 ;;
311 esac
312 fi
313 ])
314
315
316
317
318
This page was automatically generated by the LXR engine.
Free-text search provided by Glimpse