Added SILC Thread Queue API
[crypto.git] / apps / irssi / curses.m4
1 dnl Curses detection: Munged from Midnight Commander's configure.in
2 dnl
3 dnl What it does:
4 dnl =============
5 dnl
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
8 dnl   symbols 
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
11 dnl   Makefile.in's
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
16 dnl                       is found.
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
20 dnl
21 dnl Usage:
22 dnl ======
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
27 dnl
28 dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
29 dnl    #include <ncurses.h>
30 dnl    #else
31 dnl    #include <curses.h>
32 dnl    #endif
33 dnl
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
36 dnl
37 dnl Notes with automake:
38 dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
39 dnl   configure.in
40 dnl - your Makefile.am can look something like this
41 dnl   -----------------------------------------------
42 dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
43 dnl   if HAS_CURSES
44 dnl   CURSES_TARGETS=name_of_curses_prog
45 dnl   endif
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   -----------------------------------------------
52 dnl
53 dnl
54 dnl The following lines should be added to acconfig.h:
55 dnl ==================================================
56 dnl
57 dnl /*=== Curses version detection defines ===*/
58 dnl /* Found some version of curses that we're going to use */
59 dnl #undef HAS_CURSES
60 dnl    
61 dnl /* Use SunOS SysV curses? */
62 dnl #undef USE_SUNOS_CURSES
63 dnl 
64 dnl /* Use old BSD curses - not used right now */
65 dnl #undef USE_BSD_CURSES
66 dnl 
67 dnl /* Use SystemV curses? */
68 dnl #undef USE_SYSV_CURSES
69 dnl 
70 dnl /* Use Ncurses? */
71 dnl #undef USE_NCURSES
72 dnl 
73 dnl /* If you Curses does not have color define this one */
74 dnl #undef NO_COLOR_CURSES
75 dnl 
76 dnl /* Define if you want to turn on SCO-specific code */
77 dnl #undef SCO_FLAVOR
78 dnl 
79 dnl /* Set to reflect version of ncurses *
80 dnl  *   0 = version 1.*
81 dnl  *   1 = version 1.9.9g
82 dnl  *   2 = version 4.0/4.1 */
83 dnl #undef NCURSES_970530
84 dnl
85 dnl /*=== End new stuff for acconfig.h ===*/
86 dnl 
87
88
89 AC_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                 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
135           fi
136         )
137
138         if $search_ncurses
139         then
140                 AC_SEARCH_NCURSES()
141         fi
142 ])
143
144
145 AC_DEFUN(AC_USE_SUNOS_CURSES, [
146         search_ncurses=false
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)
151         has_curses=true
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)
157 ])
158
159 AC_DEFUN(AC_USE_OSF1_CURSES, [
160        AC_MSG_RESULT(Using OSF1 curses)
161        search_ncurses=false
162        screen_manager="OSF1 curses"
163        AC_DEFINE(HAS_CURSES)
164        has_curses=true
165        AC_DEFINE(NO_COLOR_CURSES)
166        AC_DEFINE(USE_SYSV_CURSES)
167        CURSES_LIBS="-lcurses"
168 ])
169
170 AC_DEFUN(AC_USE_SYSV_CURSES, [
171         AC_MSG_RESULT(Using SysV curses)
172         AC_DEFINE(HAS_CURSES)
173         has_curses=true
174         AC_DEFINE(USE_SYSV_CURSES)
175         search_ncurses=false
176         screen_manager="SysV/curses"
177         CURSES_LIBS="-lcurses"
178 ])
179
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
185 dnl     then
186 dnl         THIS_CURSES=cursesX
187 dnl        else
188 dnl         THIS_CURSES=curses
189 dnl     fi
190 dnl
191 dnl     CURSES_LIBS="-l$THIS_CURSES -ltermcap"
192 dnl     AC_DEFINE(HAS_CURSES)
193 dnl     has_curses=true
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)
199 dnl)
200
201         
202 dnl
203 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
204 dnl
205 AC_DEFUN(AC_NCURSES, [
206     if $search_ncurses
207     then
208         if test -f $1/$2
209         then
210             AC_MSG_RESULT(Found ncurses on $1/$2)
211
212             CURSES_LIBS="$3"
213             AC_CHECK_LIB(ncurses, initscr, [
214                 true;
215             ], [
216                 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
217                 AC_CHECK_LIB(curses, initscr, [
218                         CURSES_LIBS="$CHECKLIBS"
219                 ],, $CHECKLIBS)
220             ], $CURSES_LIBS)
221             CURSES_INCLUDEDIR="$4"
222             search_ncurses=false
223             screen_manager=$5
224             AC_DEFINE(HAS_CURSES)
225             has_curses=true
226             has_ncurses=true
227             AC_DEFINE(USE_NCURSES)
228         fi
229     fi
230 ])
231
232 AC_DEFUN(AC_SEARCH_NCURSES, [
233     AC_CHECKING("location of ncurses.h file")
234
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")
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)
262         has_curses=true
263         has_ncurses=true
264         AC_DEFINE(USE_NCURSES)
265         search_ncurses=false
266         screen_manager="ncurses installed as curses"
267 ])
268     fi
269
270     dnl
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
274     dnl
275     if $search_ncurses
276     then
277         if test -f /usr/5include/curses.h
278         then
279             AC_USE_SUNOS_CURSES
280         fi
281     fi
282
283     dnl use whatever curses there happens to be
284     if $search_ncurses
285     then
286         if test -f /usr/include/curses.h
287         then
288           CURSES_LIBS="-lcurses"
289           AC_DEFINE(HAS_CURSES)
290           has_curses=true
291           search_ncurses=false
292           screen_manager="curses"
293         fi
294     fi
295 ])
296