unnecessary file made by the compiler (debugger?)
[fw/sdcc] / sim / ucsim / configure.in
1 #!/bin/sh
2
3 AC_INIT(.version)
4 AC_CONFIG_HEADER(ddconfig.h:ddconfig_in.h)
5
6 AC_PROG_AWK
7
8 AC_MSG_CHECKING(version of the package)
9 if test -f .version; then
10   VERSION=`cat .version`
11   AC_MSG_RESULT($VERSION)
12 else
13   VERSION="0.0.0"
14   AC_MSG_RESULT(unknown using 0.0.0)
15 fi
16 VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'`
17 VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'`
18 VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'`
19 AC_SUBST(VERSION)
20 AC_SUBST(VERSIONHI)
21 AC_SUBST(VERSIONLO)
22 AC_SUBST(VERSIONP)
23 AC_DEFINE_UNQUOTED(VERSIONSTR, "${VERSION}")
24 AC_DEFINE_UNQUOTED(VERSIONHI, $VERSIONHI)
25 AC_DEFINE_UNQUOTED(VERSIONLO, $VERSIONLO)
26 AC_DEFINE_UNQUOTED(VERSIONP, $VERSIONP)
27
28
29 # Required programs
30 #-------------------
31 AC_PROG_CXX
32 AC_PROG_CXXCPP
33 AC_PROG_INSTALL
34 AC_PROG_RANLIB
35 AC_LANG_CPLUSPLUS
36
37
38 # Checking for header files.
39 # ===========================================================================
40
41 if test -d /stuff/include; then
42   CPPFLAGS="$CPPFLAGS -I/stuff/include"
43 fi
44
45 AC_HEADER_STDC
46 AC_CHECK_HEADERS(getopt.h)
47 AC_CHECK_HEADERS(unistd.h)
48 AC_CHECK_HEADER(sys/socket.h,
49   AC_DEFINE(SOCKET_AVAIL)
50   AC_DEFINE(HAVE_SYS_SOCKET_H))
51 AC_HEADER_DIRENT
52
53 # This must be after CXXCPP
54
55 AC_CACHE_CHECK(which header file defines FD_ macros, s51_cv_fd,
56 [s51_cv_fd="unknown"
57 AC_EGREP_CPP(yes, [
58 #include <sys/time.h>
59 #ifdef FD_ZERO
60 yes
61 #endif], s51_cv_fd="<sys/time.h>")
62 AC_EGREP_CPP(yes, [
63 #include <sys/types.h>
64 #ifdef FD_ZERO
65 yes
66 #endif], s51_cv_fd="<sys/types.h>")
67 AC_EGREP_CPP(yes, [
68 #include <sys/select.h>
69 #ifdef FD_ZERO
70 yes
71 #endif], s51_cv_fd="<sys/types.h>")])
72
73 AC_DEFINE(FD_HEADER_OK, 0)
74 if echo $s51_cv_fd|grep time >/dev/null 2>&1; then
75 AC_DEFINE(FD_NEED_TIME_H, 1)
76 AC_DEFINE(FD_HEADER_OK, 1)
77 else
78 AC_DEFINE(FD_NEED_TIME_H, 0)
79 fi
80 if echo $s51_cv_fd|grep types >/dev/null 2>&1; then
81 AC_DEFINE(FD_NEED_TYPES_H, 1)
82 AC_DEFINE(FD_HEADER_OK, 1)
83 else
84 AC_DEFINE(FD_NEED_TYPES_H, 0)
85 fi
86 if echo $s51_cv_fd|grep select >/dev/null 2>&1; then
87 AC_DEFINE(FD_NEED_SELECT_H, 1)
88 AC_DEFINE(FD_HEADER_OK, 1)
89 else
90 AC_DEFINE(FD_NEED_SELECT_H, 0)
91 fi
92
93 AC_DEFINE_UNQUOTED(HEADER_FD, ${s51_cv_fd})
94
95
96 # Checking for functions/libs
97 # ===========================================================================
98
99 AC_DEFUN(AC_CHECK_FUNC_NOCACHE,
100 [AC_MSG_CHECKING([for $1])
101 AC_TRY_LINK(
102 dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
103 dnl which includes <sys/select.h> which contains a prototype for
104 dnl select.  Similarly for bzero.
105 [/* System header to define __stub macros and hopefully few prototypes,
106     which can conflict with char $1(); below.  */
107 #include <assert.h>
108 /* Override any gcc2 internal prototype to avoid an error.  */
109 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
110 extern "C"
111 #endif
112 ])dnl
113 [/* We use char because int might match the return type of a gcc2
114     builtin and then its argument prototype would still apply.  */
115 char $1();
116 ], [
117 /* The GNU C library defines this for functions which it implements
118     to always fail with ENOSYS.  Some functions are actually named
119     something starting with __ and the normal name is an alias.  */
120 #if defined (__stub_$1) || defined (__stub___$1)
121 choke me
122 #else
123 $1();
124 #endif
125 ], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")
126 if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then
127   AC_MSG_RESULT(yes)
128   ifelse([$2], , :, [$2])
129 else
130   AC_MSG_RESULT(no)
131 ifelse([$3], , , [$3
132 ])dnl
133 fi
134 ])
135
136 AC_CHECK_LIB(socket,socket)
137 AC_CHECK_LIB(nsl,xdr_short)
138 AC_CHECK_LIB(panel,panel_above,
139 panel_ok="yes"
140 curses_ok="yes"
141 CURSES_LIBS="-lpanel -lcurses"
142 ,
143 panel_ok="no"
144 AC_CHECK_LIB(curses,nl,
145 curses_ok="yes"
146 CURSES_LIBS="-lcurses"
147 ,
148 ncurses_ok="no")
149 ,
150 -lcurses)
151 AC_SUBST(panel_ok)
152 AC_SUBST(curses_ok)
153 AC_SUBST(CURSES_LIBS)
154
155 AC_FUNC_VPRINTF
156 dnl Do not cache the result of the vasprintf test.
157 dnl This is because vasprintf is defined in the C++ runtime 
158 dnl for egcs, but not in the C runtime. Thus, caching the result
159 dnl of this test (which is done with C++) will cause later C
160 dnl based tests to falsely conclude that vasprintf is available
161 dnl to C programs.
162 dnl It's a bloody stupid function anyway. 
163 AC_CHECK_FUNC_NOCACHE(vasprintf)
164 AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
165 AC_CHECK_FUNCS(vsnprintf strchr memcpy)
166 dnl AC_CHECK_FUNCS(getline)
167 dnl AC_CHECK_FUNCS(getdelim)
168 AC_CHECK_FUNCS(fgets)
169 AC_CHECK_FUNCS(yylex)
170
171 AC_CACHE_CHECK(whether scanf knows %a, s51_cv_scanf_a,
172 [echo "a b" >conftest.data
173 AC_TRY_RUN([
174 #include <stdio.h>
175 void main(void)
176 {
177   FILE *f;
178   char *a;
179   int  i;
180   if ((f= fopen("conftest.data", "r")) == NULL)
181     exit(1);
182   i= fscanf(f, " %a[a-z] ", &a);
183   fclose(f);
184   if (i == 0)
185     exit(2);
186   if (i == 1)
187     exit(0);
188   exit(3);
189 }],
190 s51_cv_scanf_a="yes",
191 s51_cv_scanf_a="no",
192 s51_cv_scanf_a="unknown")
193 ])
194 if test "$s51_cv_scanf_a" = "yes"; then
195   AC_DEFINE(SCANF_A)
196 fi
197
198 AC_CACHE_CHECK(whether getcwd is GNUish, s51_cv_getcwd,
199 [AC_TRY_RUN([
200 #include <unistd.h>
201 void main(void)
202 {
203   if ((getcwd(NULL, 0)) == NULL)
204     exit(1);
205   exit(0);
206 }],
207 s51_cv_getcwd="yes",
208 s51_cv_getcwd="no",
209 s51_cv_getcwd="unknown")
210 ])
211 if test "$s51_cv_getcwd" = "yes"; then
212   AC_DEFINE(GNU_GETCWD)
213 fi
214
215
216 # Macro definitions
217 ###################
218
219 # DD_COPT macro checks if the compiler specified as the 1st parameter
220 # supports option specified as the 2nd parameter
221 # For example: DD_CPORT(CXX, fPIC)
222
223 AC_DEFUN(DD_COPT, [
224 AC_CACHE_CHECK(whether $$1 accepts -$2,s51_cv_$1$2,
225 cat >_test_.c <<EOF
226 #include <stdio.h>
227 void main(void) {}
228 EOF
229 $$1 -v -$2 -c _test_.c 1>&5 2>&5
230 if test "$?" = "0"; then
231   s51_cv_$1$2="yes"
232 else
233   s51_cv_$1$2="no"
234 fi
235 rm -f _test_.* a.out)
236 ])
237
238
239 # Checking characteristics of compilers and other programs
240 # --------------------------------------------------------
241 AC_C_BIGENDIAN
242 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,s51_cv_MM,
243 echo "#include <stdio.h>" >_test_.c
244 echo "" >>_test_.c
245 $CXXCPP -v -MM _test_.c 1>&5 2>&5
246 if test "$?" = "0"; then
247   s51_cv_MM="-MM"
248 else
249   s51_cv_MM="-M"
250 fi
251 rm -f _test_.*)
252 M_OR_MM=$s51_cv_MM
253 AC_SUBST(M_OR_MM)
254
255 # This is the first time when CFLAGS are set/modified!!
256
257 DD_COPT(CXX, ggdb)
258 if test "$s51_cv_CXXggdb" = "yes"; then
259     if test "$CXXFLAGS"x = x ;then
260         CXXFLAGS="-ggdb -O"
261     else
262         CXXFLAGS="$CXXFLAGS -ggdb"
263     fi
264 fi
265
266 DD_COPT(CXX, pipe)
267 if test "$s51_cv_CXXpipe" = "yes"; then
268   CXXFLAGS="$CXXFLAGS -pipe"
269 fi
270
271
272 # Checks for typedefs, structures, and compiler characteristics.
273 # ===========================================================================
274
275 AC_TYPE_SIGNAL
276 AC_CHECK_SIZEOF(char)
277 AC_CHECK_SIZEOF(short)
278 AC_CHECK_SIZEOF(int)
279 AC_CHECK_SIZEOF(long)
280 AC_CHECK_SIZEOF(long long)
281
282 type_name()
283 {
284     if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then
285         echo "char"
286         exit
287     fi
288     if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then
289         echo "short"
290         exit
291     fi
292     if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then
293         echo "int"
294         exit
295     fi
296     if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then
297         echo "long"
298         exit
299     fi
300     if expr "$ac_cv_sizeof_long_long" '>=' "$1" >/dev/null; then
301         echo "long long"
302         exit
303     fi
304     echo "long long"
305 }
306
307 AC_MSG_CHECKING(type name for byte)
308 TYPE_BYTE=`type_name 1`
309 AC_MSG_RESULT($TYPE_BYTE)
310 AC_MSG_CHECKING(type name for word)
311 TYPE_WORD=`type_name 2`
312 AC_MSG_RESULT($TYPE_WORD)
313 AC_MSG_CHECKING(type name for dword)
314 TYPE_DWORD=`type_name 4`
315 AC_MSG_RESULT($TYPE_DWORD)
316 AC_DEFINE_UNQUOTED(TYPE_BYTE, $TYPE_BYTE)
317 AC_DEFINE_UNQUOTED(TYPE_WORD, $TYPE_WORD)
318 AC_DEFINE_UNQUOTED(TYPE_DWORD, $TYPE_DWORD)
319
320 # Generating output files
321 # ===========================================================================
322
323 AC_OUTPUT(main.mk:main_in.mk
324 sim.src/Makefile
325 cmd.src/Makefile
326 s51.src/Makefile
327 avr.src/Makefile
328 z80.src/Makefile
329 gui.src/Makefile
330 gui.src/serio.src/Makefile
331 gui.src/portmon.src/Makefile
332 doc/Makefile
333 )
334
335
336 # End of configure/configure.in