source: trunk/third/gtkhtml/macros/curses.m4 @ 16767

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