1
dnl $Id: curses.m4 729 2007-01-14 13:44:38Z michael $
2
dnl $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/curses.m4 $
5
dnl Curses detection: Munged from Midnight Commander's configure.in
10
dnl - Determine which version of curses is installed on your system
11
dnl and set the -I/-L/-l compiler entries and add a few preprocessor
13
dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
14
dnl @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
16
dnl - Modify the following configure variables (these are the only
17
dnl curses.m4 variables you can access from within configure.in)
18
dnl CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
19
dnl an ncurses.h that's been renamed to curses.h
21
dnl CURSES_LIBS - sets -L and -l's appropriately
22
dnl CFLAGS - if --with-sco, add -D_SVID3
23
dnl has_curses - exports result of tests to rest of configure
27
dnl 1) Add lines indicated below to acconfig.h
28
dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
29
dnl 3) Instead of #include <curses.h> you should use the following to
30
dnl properly locate ncurses or curses header file
32
dnl #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
33
dnl #include <ncurses.h>
35
dnl #include <curses.h>
38
dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
39
dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
41
dnl Notes with automake:
42
dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
44
dnl - your Makefile.am can look something like this
45
dnl -----------------------------------------------
46
dnl INCLUDES= blah blah blah $(CURSES_INCLUDEDIR)
48
dnl CURSES_TARGETS=name_of_curses_prog
50
dnl bin_PROGRAMS = other_programs $(CURSES_TARGETS)
51
dnl other_programs_SOURCES = blah blah blah
52
dnl name_of_curses_prog_SOURCES = blah blah blah
53
dnl other_programs_LDADD = blah
54
dnl name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
55
dnl -----------------------------------------------
58
dnl The following lines should be added to acconfig.h:
59
dnl ==================================================
61
dnl /*=== Curses version detection defines ===*/
62
dnl /* Found some version of curses that we're going to use */
65
dnl /* Use SunOS SysV curses? */
66
dnl #undef USE_SUNOS_CURSES
68
dnl /* Use old BSD curses - not used right now */
69
dnl #undef USE_BSD_CURSES
71
dnl /* Use SystemV curses? */
72
dnl #undef USE_SYSV_CURSES
74
dnl /* Use Ncurses? */
75
dnl #undef USE_NCURSES
77
dnl /* If you Curses does not have color define this one */
78
dnl #undef NO_COLOR_CURSES
80
dnl /* Define if you want to turn on SCO-specific code */
83
dnl /* Set to reflect version of ncurses *
85
dnl * 1 = version 1.9.9g
86
dnl * 2 = version 4.0/4.1 */
87
dnl #undef NCURSES_970530
89
dnl /*=== End new stuff for acconfig.h ===*/
93
AC_DEFUN([AC_CHECK_CURSES],[
100
AC_SUBST(CURSES_LIBS)
101
AC_SUBST(CURSES_INCLUDEDIR)
104
[ --with-sco Use this to turn on SCO-specific code],[
105
if test x$withval = xyes; then
106
AC_DEFINE(SCO_FLAVOR,1,[Define if you want to turn on SCO-specific code])
107
CFLAGS="$CFLAGS -D_SVID3"
111
AC_ARG_WITH(sunos-curses,
112
[ --with-sunos-curses Used to force SunOS 4.x curses],[
113
if test x$withval = xyes; then
118
AC_ARG_WITH(osf1-curses,
119
[ --with-osf1-curses Used to force OSF/1 curses],[
120
if test x$withval = xyes; then
126
[ --with-vcurses[=incdir] Used to force SysV curses],
127
if test x$withval != xyes; then
128
CURSES_INCLUDEDIR="-I$withval"
134
[ --with-ncurses[=dir] Compile with ncurses/locate base dir],
135
if test x$withval = xno ; then
137
elif test x$withval != xyes ; then
138
CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
139
CURSES_INCLUDEDIR="-I$withval/include"
141
screen_manager="ncurses"
142
AC_DEFINE(USE_NCURSES,1,[Use Ncurses?])
143
AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
157
AC_DEFUN([AC_USE_SUNOS_CURSES], [
159
screen_manager="SunOS 4.x /usr/5include curses"
160
AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
161
AC_DEFINE(USE_SUNOS_CURSES,1,[Use SunOS SysV curses?])
162
AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
164
AC_DEFINE(NO_COLOR_CURSES,1,[If you Curses does not have color define this one])
165
AC_DEFINE(USE_SYSV_CURSES,1,[Use SystemV curses?])
166
CURSES_INCLUDEDIR="-I/usr/5include"
167
CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
168
AC_MSG_RESULT(Please note that some screen refreshs may fail)
171
AC_DEFUN([AC_USE_OSF1_CURSES], [
172
AC_MSG_RESULT(Using OSF1 curses)
174
screen_manager="OSF1 curses"
175
AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
177
AC_DEFINE(NO_COLOR_CURSES,1,[If you Curses does not have color define this one])
178
AC_DEFINE(USE_SYSV_CURSES,1,[Use SystemV curses?])
179
CURSES_LIBS="-lcurses"
182
AC_DEFUN([AC_USE_SYSV_CURSES], [
183
AC_MSG_RESULT(Using SysV curses)
184
AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
186
AC_DEFINE(USE_SYSV_CURSES,1,[Use SystemV curses?])
188
screen_manager="SysV/curses"
189
CURSES_LIBS="-lcurses"
192
dnl AC_ARG_WITH(bsd-curses,
193
dnl [--with-bsd-curses Used to compile with bsd curses, not very fancy],
194
dnl search_ncurses=false
195
dnl screen_manager="Ultrix/cursesX"
196
dnl if test $system = ULTRIX
198
dnl THIS_CURSES=cursesX
200
dnl THIS_CURSES=curses
203
dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap"
204
dnl AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
206
dnl AC_DEFINE(USE_BSD_CURSES,1,[Use old BSD curses - not used right now])
207
dnl AC_MSG_RESULT(Please note that some screen refreshs may fail)
208
dnl AC_MSG_WARN(Use of the bsdcurses extension has some)
209
dnl AC_MSG_WARN(display/input problems.)
210
dnl AC_MSG_WARN(Reconsider using xcurses)
215
dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
217
AC_DEFUN([AC_NCURSES], [
222
AC_MSG_RESULT(Found ncurses on $1/$2)
224
CURSES_INCLUDEDIR="$4"
227
AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
229
AC_DEFINE(USE_NCURSES,1,[Use Ncurses?])
234
AC_DEFUN([AC_SEARCH_NCURSES], [
235
AC_CHECKING(location of ncurses.h file)
237
AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
238
AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
239
AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
240
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")
242
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")
244
AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
247
dnl We couldn't find ncurses, try SysV curses
251
AC_EGREP_HEADER(init_color, /usr/include/curses.h,
253
AC_EGREP_CPP(USE_NCURSES,[
260
CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
261
AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
263
AC_DEFINE(USE_NCURSES,1,[Use Ncurses?])
265
screen_manager="ncurses installed as curses"
270
dnl Try SunOS 4.x /usr/5{lib,include} ncurses
271
dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
272
dnl should be replaced by a more fine grained selection routine
276
if test -f /usr/5include/curses.h
281
# check for ncurses version, to properly ifdef mouse-fix
282
AC_MSG_CHECKING(for ncurses version)
283
ncurses_version=unknown
284
cat > conftest.$ac_ext <<EOF
285
[#]line __oline__ "configure"
286
#include "confdefs.h"
287
#ifdef RENAMED_NCURSES
293
VERSION:NCURSES_VERSION
295
if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
296
egrep "VERSION:" >conftest.out 2>&1; then
298
ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
302
AC_MSG_RESULT($ncurses_version)
303
case "$ncurses_version" in
307
AC_DEFINE(NCURSES_970530,2,[Set to reflect version of ncurses])
310
AC_DEFINE(NCURSES_970530,1,[Set to reflect version of ncurses])
313
AC_DEFINE(NCURSES_970530,0,[Set to reflect version of ncurses])