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 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
145 AC_DEFUN(AC_USE_SUNOS_CURSES, [
147 screen_manager="SunOS 4.x /usr/5include curses"
148 AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
149 AC_DEFINE(USE_SUNOS_CURSES)
150 AC_DEFINE(HAS_CURSES)
152 AC_DEFINE(NO_COLOR_CURSES)
153 AC_DEFINE(USE_SYSV_CURSES)
154 CURSES_INCLUDEDIR="-I/usr/5include"
155 CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
156 AC_MSG_RESULT(Please note that some screen refreshs may fail)
159 AC_DEFUN(AC_USE_OSF1_CURSES, [
160 AC_MSG_RESULT(Using OSF1 curses)
162 screen_manager="OSF1 curses"
163 AC_DEFINE(HAS_CURSES)
165 AC_DEFINE(NO_COLOR_CURSES)
166 AC_DEFINE(USE_SYSV_CURSES)
167 CURSES_LIBS="-lcurses"
170 AC_DEFUN(AC_USE_SYSV_CURSES, [
171 AC_MSG_RESULT(Using SysV curses)
172 AC_DEFINE(HAS_CURSES)
174 AC_DEFINE(USE_SYSV_CURSES)
176 screen_manager="SysV/curses"
177 CURSES_LIBS="-lcurses"
180 dnl AC_ARG_WITH(bsd-curses,
181 dnl [--with-bsd-curses Used to compile with bsd curses, not very fancy],
182 dnl search_ncurses=false
183 dnl screen_manager="Ultrix/cursesX"
184 dnl if test $system = ULTRIX
186 dnl THIS_CURSES=cursesX
188 dnl THIS_CURSES=curses
191 dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap"
192 dnl AC_DEFINE(HAS_CURSES)
194 dnl AC_DEFINE(USE_BSD_CURSES)
195 dnl AC_MSG_RESULT(Please note that some screen refreshs may fail)
196 dnl AC_WARN(Use of the bsdcurses extension has some)
197 dnl AC_WARN(display/input problems.)
198 dnl AC_WARN(Reconsider using xcurses)
203 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
205 AC_DEFUN(AC_NCURSES, [
210 AC_MSG_RESULT(Found ncurses on $1/$2)
213 AC_CHECK_LIB(ncurses, initscr, [
216 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
217 AC_CHECK_LIB(curses, initscr, [
218 CURSES_LIBS="$CHECKLIBS"
221 CURSES_INCLUDEDIR="$4"
224 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/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
239 AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
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)
264 AC_DEFINE(USE_NCURSES)
266 screen_manager="ncurses installed as curses"
271 dnl Try SunOS 4.x /usr/5{lib,include} ncurses
272 dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
273 dnl should be replaced by a more fine grained selection routine
277 if test -f /usr/5include/curses.h
283 dnl use whatever curses there happens to be
286 if test -f /usr/include/curses.h
288 CURSES_LIBS="-lcurses"
289 AC_DEFINE(HAS_CURSES)
292 screen_manager="curses"