~siretart/lcd4linux/debian

« back to all changes in this revision

Viewing changes to curses.m4

  • Committer: Reinhard Tartler
  • Date: 2011-04-27 17:24:15 UTC
  • mto: This revision was merged to the branch mainline in revision 750.
  • Revision ID: siretart@tauware.de-20110427172415-6n4aptmvmz0eztvm
Tags: upstream-0.11.0~svn1143
ImportĀ upstreamĀ versionĀ 0.11.0~svn1143

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl $Id: curses.m4 729 2007-01-14 13:44:38Z michael $
 
2
dnl $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/curses.m4 $
 
3
 
 
4
 
 
5
dnl Curses detection: Munged from Midnight Commander's configure.in
 
6
dnl
 
7
dnl What it does:
 
8
dnl =============
 
9
dnl
 
10
dnl - Determine which version of curses is installed on your system
 
11
dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
 
12
dnl   symbols 
 
13
dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
 
14
dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
 
15
dnl   Makefile.in's
 
16
dnl - Modify the following configure variables (these are the only
 
17
dnl   curses.m4 variables you can access from within configure.in)
 
18
dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
 
19
dnl                       an ncurses.h that's been renamed to curses.h
 
20
dnl                       is found.
 
21
dnl   CURSES_LIBS       - sets -L and -l's appropriately
 
22
dnl   CFLAGS            - if --with-sco, add -D_SVID3 
 
23
dnl   has_curses        - exports result of tests to rest of configure
 
24
dnl
 
25
dnl Usage:
 
26
dnl ======
 
27
dnl 1) Add lines indicated below to acconfig.h
 
28
dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
 
29
dnl 3) Instead of #include <curses.h> you should use the following to
 
30
dnl    properly locate ncurses or curses header file
 
31
dnl
 
32
dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
 
33
dnl    #include <ncurses.h>
 
34
dnl    #else
 
35
dnl    #include <curses.h>
 
36
dnl    #endif
 
37
dnl
 
38
dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
 
39
dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
 
40
dnl
 
41
dnl Notes with automake:
 
42
dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
 
43
dnl   configure.in
 
44
dnl - your Makefile.am can look something like this
 
45
dnl   -----------------------------------------------
 
46
dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
 
47
dnl   if HAS_CURSES
 
48
dnl   CURSES_TARGETS=name_of_curses_prog
 
49
dnl   endif
 
50
dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
 
51
dnl   other_programs_SOURCES = blah blah blah
 
52
dnl   name_of_curses_prog_SOURCES = blah blah blah
 
53
dnl   other_programs_LDADD = blah
 
54
dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
 
55
dnl   -----------------------------------------------
 
56
dnl
 
57
dnl
 
58
dnl The following lines should be added to acconfig.h:
 
59
dnl ==================================================
 
60
dnl
 
61
dnl /*=== Curses version detection defines ===*/
 
62
dnl /* Found some version of curses that we're going to use */
 
63
dnl #undef HAS_CURSES
 
64
dnl    
 
65
dnl /* Use SunOS SysV curses? */
 
66
dnl #undef USE_SUNOS_CURSES
 
67
dnl 
 
68
dnl /* Use old BSD curses - not used right now */
 
69
dnl #undef USE_BSD_CURSES
 
70
dnl 
 
71
dnl /* Use SystemV curses? */
 
72
dnl #undef USE_SYSV_CURSES
 
73
dnl 
 
74
dnl /* Use Ncurses? */
 
75
dnl #undef USE_NCURSES
 
76
dnl 
 
77
dnl /* If you Curses does not have color define this one */
 
78
dnl #undef NO_COLOR_CURSES
 
79
dnl 
 
80
dnl /* Define if you want to turn on SCO-specific code */
 
81
dnl #undef SCO_FLAVOR
 
82
dnl 
 
83
dnl /* Set to reflect version of ncurses *
 
84
dnl  *   0 = version 1.*
 
85
dnl  *   1 = version 1.9.9g
 
86
dnl  *   2 = version 4.0/4.1 */
 
87
dnl #undef NCURSES_970530
 
88
dnl
 
89
dnl /*=== End new stuff for acconfig.h ===*/
 
90
dnl 
 
91
 
 
92
 
 
93
AC_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
 
 
157
AC_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
 
 
171
AC_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
 
 
182
AC_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
 
 
192
dnl AC_ARG_WITH(bsd-curses,
 
193
dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
 
194
dnl     search_ncurses=false
 
195
dnl     screen_manager="Ultrix/cursesX"
 
196
dnl     if test $system = ULTRIX
 
197
dnl     then
 
198
dnl         THIS_CURSES=cursesX
 
199
dnl        else
 
200
dnl         THIS_CURSES=curses
 
201
dnl     fi
 
202
dnl
 
203
dnl     CURSES_LIBS="-l$THIS_CURSES -ltermcap"
 
204
dnl     AC_DEFINE(HAS_CURSES,1,[Found some version of curses that we're going to use])
 
205
dnl     has_curses=true
 
206
dnl     AC_DEFINE(USE_BSD_CURSES,1,[Use old BSD curses - not used right now])
 
207
dnl     AC_MSG_RESULT(Please note that some screen refreshs may fail)
 
208
dnl     AC_MSG_WARN(Use of the bsdcurses extension has some)
 
209
dnl     AC_MSG_WARN(display/input problems.)
 
210
dnl     AC_MSG_WARN(Reconsider using xcurses)
 
211
dnl)
 
212
 
 
213
        
 
214
dnl
 
215
dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
 
216
dnl
 
217
AC_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
 
 
234
AC_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
 
257
USE_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
 
284
cat > 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
 
293
VERSION:NCURSES_VERSION
 
294
EOF
 
295
        if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
 
296
  egrep "VERSION:" >conftest.out 2>&1; then
 
297
changequote(,)dnl
 
298
            ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
 
299
changequote([,])dnl
 
300
        fi
 
301
        rm -rf conftest*
 
302
        AC_MSG_RESULT($ncurses_version)
 
303
        case "$ncurses_version" in
 
304
changequote(,)dnl
 
305
        4.[01])
 
306
changequote([,])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
 
 
322