root/trunk/curses.m4

Revision 729, 9.6 kB (checked in by michael, 23 months ago)

added svn properties and keywords

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