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