1
dnl Curses detection: Munged from Midnight Commander's configure.in
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
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
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
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
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
28
dnl #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
29
dnl #include <ncurses.h>
31
dnl #include <curses.h>
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
37
dnl Notes with automake:
38
dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
40
dnl - your Makefile.am can look something like this
41
dnl -----------------------------------------------
42
dnl INCLUDES= blah blah blah $(CURSES_INCLUDEDIR)
44
dnl CURSES_TARGETS=name_of_curses_prog
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 -----------------------------------------------
54
dnl The following lines should be added to acconfig.h:
55
dnl ==================================================
57
dnl /*=== Curses version detection defines ===*/
58
dnl /* Found some version of curses that we're going to use */
61
dnl /* Use SunOS SysV curses? */
62
dnl #undef USE_SUNOS_CURSES
64
dnl /* Use old BSD curses - not used right now */
65
dnl #undef USE_BSD_CURSES
67
dnl /* Use SystemV curses? */
68
dnl #undef USE_SYSV_CURSES
70
dnl /* Use Ncurses? */
71
dnl #undef USE_NCURSES
73
dnl /* If you Curses does not have color define this one */
74
dnl #undef NO_COLOR_CURSES
76
dnl /* Define if you want to turn on SCO-specific code */
79
dnl /* Set to reflect version of ncurses *
81
dnl * 1 = version 1.9.9g
82
dnl * 2 = version 4.0/4.1 */
83
dnl #undef NCURSES_970530
85
dnl /*=== End new stuff for acconfig.h ===*/
89
AC_DEFUN([AC_CHECK_CURSES],[
97
AC_SUBST(CURSES_INCLUDEDIR)
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"
107
AC_ARG_WITH(sunos-curses,
108
[ --with-sunos-curses Used to force SunOS 4.x curses],[
109
if test x$withval = xyes; then
114
AC_ARG_WITH(osf1-curses,
115
[ --with-osf1-curses Used to force OSF/1 curses],[
116
if test x$withval = xyes; then
122
[ --with-vcurses[=incdir] Used to force SysV curses],
123
if test x$withval != xyes; then
124
CURSES_INCLUDEDIR="-I$withval"
130
[ --with-ncurses[=dir] Compile with ncurses/locate base dir],
131
if test x$withval = xno ; then
133
elif test x$withval != xyes ; then
134
CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
135
CURSES_INCLUDEDIR="-I$withval/include"
137
screen_manager="ncurses"
138
AC_DEFINE(USE_NCURSES)
139
AC_DEFINE(HAS_CURSES)
153
AC_DEFUN([AC_USE_SUNOS_CURSES], [
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)
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)
167
AC_DEFUN([AC_USE_OSF1_CURSES], [
168
AC_MSG_RESULT(Using OSF1 curses)
170
screen_manager="OSF1 curses"
171
AC_DEFINE(HAS_CURSES)
173
AC_DEFINE(NO_COLOR_CURSES)
174
AC_DEFINE(USE_SYSV_CURSES)
175
CURSES_LIBS="-lcurses"
178
AC_DEFUN([AC_USE_SYSV_CURSES], [
179
AC_MSG_RESULT(Using SysV curses)
180
AC_DEFINE(HAS_CURSES)
182
AC_DEFINE(USE_SYSV_CURSES)
184
screen_manager="SysV/curses"
185
CURSES_LIBS="-lcurses"
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
194
dnl THIS_CURSES=cursesX
196
dnl THIS_CURSES=curses
199
dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap"
200
dnl AC_DEFINE(HAS_CURSES)
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)
211
dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
213
AC_DEFUN([AC_NCURSES], [
218
AC_MSG_RESULT(Found ncurses on $1/$2)
220
CURSES_INCLUDEDIR="$4"
223
AC_DEFINE(HAS_CURSES)
225
AC_DEFINE(USE_NCURSES)
230
AC_DEFUN([AC_SEARCH_NCURSES], [
231
AC_CHECKING("location of ncurses.h file")
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")
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")
240
AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
243
dnl We couldn't find ncurses, try SysV curses
247
AC_EGREP_HEADER(init_color, /usr/include/curses.h,
249
AC_EGREP_CPP(USE_NCURSES,[
256
CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
257
AC_DEFINE(HAS_CURSES)
259
AC_DEFINE(USE_NCURSES)
261
screen_manager="ncurses installed as curses"
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
272
if test -f /usr/5include/curses.h
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
289
VERSION:NCURSES_VERSION
291
if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
292
egrep "VERSION:" >conftest.out 2>&1; then
294
ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
298
AC_MSG_RESULT($ncurses_version)
299
case "$ncurses_version" in
303
AC_DEFINE(NCURSES_970530,2)
306
AC_DEFINE(NCURSES_970530,1)
309
AC_DEFINE(NCURSES_970530,0)