* configure.in, configure, sdccconf_in.h, src/SDCCglobal,
[fw/sdcc] / debugger / mcs51 / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4-p6
2
3 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl Scott Dattalo
14 dnl
15 dnl  This is copied from the NcFTP distribution.
16 dnl  Author Mike Gleason mgleason@NcFTP.com
17 dnl
18 dnl This macro will check for the presence and version
19 dnl of the readline library. To get it into the aclocal.m4
20 dnl file, do this:
21 dnl   aclocal -I . --verbose
22 dnl
23 dnl The --verbose will show all of the files that are searched
24 dnl for .m4 macros.
25 AC_DEFUN([wi_LIB_READLINE], [
26 AC_MSG_CHECKING([for GNU Readline library, version 2.0 or newer])
27
28 wi_cv_lib_readline=no
29 wi_cv_lib_readline_result=no
30 ac_save_LIBS="$LIBS"
31 # Note: $LIBCURSES is permitted to be empty.
32 for LIBREADLINE in "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses"
33 do
34         LIBS="$ac_save_LIBS $LIBREADLINE"
35         AC_TRY_RUN([
36         /* program */
37 #include <stdio.h>
38 #include <stdlib.h>
39
40 main(int argc, char **argv)
41 {
42         /* Note:  don't actually call readline, since it may block;
43          * We just want to see if it (dynamic) linked in okay.
44          */
45         if (argc == 0)  /* never true */
46                 readline(0);
47         exit(0);
48 }
49 ],[
50         # action if true
51         wi_cv_lib_readline=yes
52 ],[
53         # action if false
54         wi_cv_lib_readline=no
55 ],[
56         # action if cross compiling
57         wi_cv_lib_readline=no
58 ])
59
60         if test "$wi_cv_lib_readline" = yes ; then break ; fi
61 done
62
63 # Now try it again, to be sure it is recent enough.
64 # rl_function_of_keyseq appeared in version 2.0
65 #
66 dnl AC_CHECK_FUNC(rl_function_of_keyseq, [wi_cv_lib_readline=yes],[
67 dnl     wi_cv_lib_readline=no;wi_cv_lib_readline_result="no (it is present but too old to use)"
68 dnl ])
69         AC_TRY_LINK([
70                 /* includes */
71         ],[
72                 /* function-body */
73                 readline(0);
74                 rl_function_of_keyseq(0);
75         ],[
76                 wi_cv_lib_readline=yes
77         ],[
78                 wi_cv_lib_readline=no
79                 wi_cv_lib_readline_result="no (it is present but too old to use)"
80         ])
81
82 if test "$wi_cv_lib_readline" = no ; then
83         LIBREADLINE=""
84         # restore LIBS
85         LIBS="$ac_save_LIBS"
86 else
87         /bin/rm -f readline.ver
88         touch readline.ver
89
90         AC_TRY_RUN([
91         /* program */
92 #include <unistd.h>
93 #include <sys/types.h>
94 #include <stdio.h>
95
96 extern char *rl_library_version;
97
98 main()
99 {
100         FILE *fp;
101         double d;
102
103         sscanf(rl_library_version, "%lf", &d);
104         fp = fopen("readline.ver", "w");
105         if (fp == NULL) exit(1);
106         if (fprintf(fp, "%s\n", rl_library_version) < 0) exit(1);
107         if (fprintf(fp, "%03d\n", (int) (d * 100.0)) < 0) exit(1);
108         if (fclose(fp) < 0) exit(1);
109         exit(0);
110 }
111         ],[
112                 # action if true
113                 rl_library_version=`sed -n 1,1p readline.ver 2>/dev/null`
114                 rlver=`sed -n 2,2p readline.ver 2>/dev/null`
115                 /bin/rm -f readline.ver
116         ],[
117                 # action if false
118                 rl_library_version=''
119                 rlver=''
120                 /bin/rm -f readline.ver
121         ],[
122                 # action if cross compiling
123                 rl_library_version=''
124                 rlver=''
125                 /bin/rm -f readline.ver
126         ])
127
128         case "$rlver" in
129                 ???)
130                         wi_cv_lib_readline_result="yes, installed version is $rl_library_version"
131                         ;;
132                 *)
133                         # Test using current LIBS.
134                         AC_TRY_LINK([
135                                 /* includes */
136                                 extern int rl_completion_append_character;
137                         ],[
138                                 /* function-body */
139                                 readline(0);
140                                 rl_completion_append_character = 0;
141                         ],[
142                                 rlver="210"
143                         ],[
144                                 rlver="200"
145                         ])
146
147                         if test "$rlver" = "210" ; then
148                                 wi_cv_lib_readline_result="yes, version 2.1 or higher"
149                         else
150                                 wi_cv_lib_readline_result="yes, version 2.0"
151                         fi
152                         ;;
153         esac
154
155         wi_cv_lib_readline=yes
156         # restore LIBS
157         LIBS="$ac_save_LIBS"
158 fi
159 AC_MSG_RESULT($wi_cv_lib_readline_result)
160 AC_SUBST(LIBREADLINE)
161
162 if test "$wi_cv_lib_readline" = yes ; then
163         # Now verify that all the headers are installed.
164         #
165         AC_REQUIRE_CPP()
166         unset ac_cv_header_readline_chardefs_h
167         unset ac_cv_header_readline_history_h
168         unset ac_cv_header_readline_keymaps_h
169         unset ac_cv_header_readline_readline_h
170         unset ac_cv_header_readline_tilde_h
171         AC_CHECK_HEADERS([readline/chardefs.h readline/history.h readline/keymaps.h readline/readline.h readline/tilde.h])
172
173         for xxwi in \
174                 "$ac_cv_header_readline_chardefs_h" \
175                 "$ac_cv_header_readline_history_h" \
176                 "$ac_cv_header_readline_keymaps_h" \
177                 "$ac_cv_header_readline_readline_h" \
178                 "$ac_cv_header_readline_tilde_h"
179         do
180                 if test "$xxwi" = no ; then
181                         break
182                 fi
183         done
184
185         if test "$xxwi" = no ; then
186                 AC_MSG_WARN([GNU Readline headers are not installed or could not be found -- GNU Readline will not be used.])
187                 wi_cv_lib_readline=no
188                 wi_cv_lib_readline_result="no (headers not installed)"
189         else
190                 AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $rlver,[Readline])
191         fi
192 fi
193         dnl Check to see if we have a namespace clean version of readline
194         dnl or not. At least FreeBSD 4.9 ships with non-ns-clean readline.
195         if test "$wi_cv_lib_readline" = "yes" ; then
196                 ac_save_LIBS="$LIBS"
197                 LIBS="$ac_save_LIBS $LIBREADLINE"
198                 AC_CHECK_FUNCS(rl_completion_matches completion_matches)
199                 # restore LIBS
200                 LIBS="$ac_save_LIBS"
201         fi
202         dnl Check to see if rl_callback_handler_install takes a cast
203         AC_MSG_CHECKING([to see if readline callbacks take a cast])
204         ac_save_LIBS="$LIBS"
205         LIBS="$ac_save_LIBS $LIBREADLINE"
206         ac_save_CC="$CC"
207         CC="$CXX"
208         AC_TRY_LINK([
209 #include <stdio.h>
210 #include <readline/readline.h>
211 void func(void) { return; }
212         ],[
213                 rl_callback_handler_install(">", (void(*)(char*))func);
214         ],[
215                 AC_DEFINE(READLINE_CB_TAKES_CAST, 1, [callbacks take a cast])
216                 AC_MSG_RESULT([yes])
217         ],[
218                 AC_MSG_RESULT([no])
219         ])
220         # restore LIBS
221         LIBS="$ac_save_LIBS"
222         CC="$ac_save_CC"
223 ])
224 dnl
225 dnl
226