1 dnl curses.m4 stolen from gnome-1 macros - needed for gdialog
3 dnl Curses detection: Munged from Midnight Commander's configure.in
8 dnl - Determine which version of curses is installed on your system
9 dnl and set the -I/-L/-l compiler entries and add a few preprocessor
11 dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
12 dnl @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
14 dnl - Modify the following configure variables (these are the only
15 dnl curses.m4 variables you can access from within configure.in)
16 dnl CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
17 dnl an ncurses.h that's been renamed to curses.h
19 dnl CURSES_LIBS - sets -L and -l's appropriately
20 dnl CFLAGS - if --with-sco, add -D_SVID3
21 dnl has_curses - exports result of tests to rest of configure
25 dnl 1) Add lines indicated below to acconfig.h
26 dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
27 dnl 3) Instead of #include <curses.h> you should use the following to
28 dnl properly locate ncurses or curses header file
30 dnl #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
31 dnl #include <ncurses.h>
33 dnl #include <curses.h>
36 dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
37 dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
39 dnl Notes with automake:
40 dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
42 dnl - your Makefile.am can look something like this
43 dnl -----------------------------------------------
44 dnl INCLUDES= blah blah blah $(CURSES_INCLUDEDIR)
46 dnl CURSES_TARGETS=name_of_curses_prog
48 dnl bin_PROGRAMS = other_programs $(CURSES_TARGETS)
49 dnl other_programs_SOURCES = blah blah blah
50 dnl name_of_curses_prog_SOURCES = blah blah blah
51 dnl other_programs_LDADD = blah
52 dnl name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
53 dnl -----------------------------------------------
56 dnl The following lines should be added to acconfig.h:
57 dnl ==================================================
59 dnl /*=== Curses version detection defines ===*/
60 dnl /* Found some version of curses that we're going to use */
63 dnl /* Use SunOS SysV curses? */
64 dnl #undef USE_SUNOS_CURSES
66 dnl /* Use old BSD curses - not used right now */
67 dnl #undef USE_BSD_CURSES
69 dnl /* Use SystemV curses? */
70 dnl #undef USE_SYSV_CURSES
72 dnl /* Use Ncurses? */
73 dnl #undef USE_NCURSES
75 dnl /* If you Curses does not have color define this one */
76 dnl #undef NO_COLOR_CURSES
78 dnl /* Define if you want to turn on SCO-specific code */
81 dnl /* Set to reflect version of ncurses *
83 dnl * 1 = version 1.9.9g
84 dnl * 2 = version 4.0/4.1 */
85 dnl #undef NCURSES_970530
87 dnl /*=== End new stuff for acconfig.h ===*/
91 AC_DEFUN([AC_CHECK_CURSES],[
99 AC_SUBST(CURSES_INCLUDEDIR)
102 [ --with-sco Use this to turn on SCO-specific code],[
103 if test x$withval = xyes; then
104 AC_DEFINE(SCO_FLAVOR)
105 CFLAGS="$CFLAGS -D_SVID3"
109 AC_ARG_WITH(sunos-curses,
110 [ --with-sunos-curses Used to force SunOS 4.x curses],[
111 if test x$withval = xyes; then
116 AC_ARG_WITH(osf1-curses,
117 [ --with-osf1-curses Used to force OSF/1 curses],[
118 if test x$withval = xyes; then
124 [ --with-vcurses[=incdir] Used to force SysV curses],
125 if test x$withval != xyes; then
126 CURSES_INCLUDEDIR="-I$withval"
132 [ --with-ncurses[=dir] Compile with ncurses/locate base dir],
133 if test x$withval = xno ; then
135 elif test x$withval != xyes ; then
136 CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
137 CURSES_INCLUDEDIR="-I$withval/include"
139 screen_manager="ncurses"
140 AC_DEFINE(USE_NCURSES)
141 AC_DEFINE(HAS_CURSES)
155 AC_DEFUN([AC_USE_SUNOS_CURSES], [
157 screen_manager="SunOS 4.x /usr/5include curses"
158 AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
159 AC_DEFINE(USE_SUNOS_CURSES)
160 AC_DEFINE(HAS_CURSES)
162 AC_DEFINE(NO_COLOR_CURSES)
163 AC_DEFINE(USE_SYSV_CURSES)
164 CURSES_INCLUDEDIR="-I/usr/5include"
165 CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
166 AC_MSG_RESULT(Please note that some screen refreshs may fail)
169 AC_DEFUN([AC_USE_OSF1_CURSES], [
170 AC_MSG_RESULT(Using OSF1 curses)
172 screen_manager="OSF1 curses"
173 AC_DEFINE(HAS_CURSES)
175 AC_DEFINE(NO_COLOR_CURSES)
176 AC_DEFINE(USE_SYSV_CURSES)
177 CURSES_LIBS="-lcurses"
180 AC_DEFUN([AC_USE_SYSV_CURSES], [
181 AC_MSG_RESULT(Using SysV curses)
182 AC_DEFINE(HAS_CURSES)
184 AC_DEFINE(USE_SYSV_CURSES)
186 screen_manager="SysV/curses"
187 CURSES_LIBS="-lcurses"
190 dnl AC_ARG_WITH(bsd-curses,
191 dnl [--with-bsd-curses Used to compile with bsd curses, not very fancy],
192 dnl search_ncurses=false
193 dnl screen_manager="Ultrix/cursesX"
194 dnl if test $system = ULTRIX
196 dnl THIS_CURSES=cursesX
198 dnl THIS_CURSES=curses
201 dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap"
202 dnl AC_DEFINE(HAS_CURSES)
204 dnl AC_DEFINE(USE_BSD_CURSES)
205 dnl AC_MSG_RESULT(Please note that some screen refreshs may fail)
206 dnl AC_MSG_WARN(Use of the bsdcurses extension has some)
207 dnl AC_MSG_WARN(display/input problems.)
208 dnl AC_MSG_WARN(Reconsider using xcurses)
213 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
215 AC_DEFUN([AC_NCURSES], [
220 AC_MSG_RESULT(Found ncurses on $1/$2)
222 CURSES_INCLUDEDIR="$4"
225 AC_DEFINE(HAS_CURSES)
227 AC_DEFINE(USE_NCURSES)
232 AC_DEFUN([AC_SEARCH_NCURSES], [
233 AC_CHECKING("location of ncurses.h file")
235 AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
236 AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
237 AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
238 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")
240 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")
242 AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
245 dnl We couldn't find ncurses, try SysV curses
249 AC_EGREP_HEADER(init_color, /usr/include/curses.h,
251 AC_EGREP_CPP(USE_NCURSES,[
258 CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
259 AC_DEFINE(HAS_CURSES)
261 AC_DEFINE(USE_NCURSES)
263 screen_manager="ncurses installed as curses"
268 dnl Try SunOS 4.x /usr/5{lib,include} ncurses
269 dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
270 dnl should be replaced by a more fine grained selection routine
274 if test -f /usr/5include/curses.h
279 # check for ncurses version, to properly ifdef mouse-fix
280 AC_MSG_CHECKING(for ncurses version)
281 ncurses_version=unknown
282 cat > conftest.$ac_ext <<EOF
283 [#]line __oline__ "configure"
284 #include "confdefs.h"
285 #ifdef RENAMED_NCURSES
291 VERSION:NCURSES_VERSION
293 if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
294 egrep "VERSION:" >conftest.out 2>&1; then
296 ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
300 AC_MSG_RESULT($ncurses_version)
301 case "$ncurses_version" in
305 AC_DEFINE(NCURSES_970530,2)
308 AC_DEFINE(NCURSES_970530,1)
311 AC_DEFINE(NCURSES_970530,0)