]> git.gag.com Git - fw/sdcc/blob - sim/ucsim/configure.in
* sim/ucsim/configure, sim/ucsim/cmd.src/newcmdcl.h,
[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 ${srcdir}/.version; then
10   VERSION=`cat ${srcdir}/.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 # Some options
29 #==============
30 # *nix default: "${datadir}/sdcc/doc"
31 AC_ARG_VAR(docdir, documentation installation directory)
32 if test "${docdir}" = ""; then
33     docdir="\${datadir}"/sdcc/doc
34 fi
35 AC_SUBST(docdir)
36
37 AC_ARG_ENABLE(ucsim,
38 [  --enable-ucsim          compile ucsim frontend],
39 if test $enable_ucsim != "no"; then
40     enable_ucsim="yes"
41 fi,
42 #default
43 enable_ucsim="no")
44 AC_ARG_ENABLE(dlso,
45 [  --enable-dlso           compile dynamically loadable shared libraries],
46 if test $enable_dlso != "no"; then
47     enable_dlso="yes"
48 fi,
49 enable_dlso="no")
50 AC_ARG_ENABLE(51,
51 [  --disable-51            do not compile simulator for MCS51],
52 if test $enable_51 != "no"; then
53     enable_51="yes"
54 fi,
55 enable_51="yes")
56 AC_ARG_ENABLE(avr,
57 [  --disable-avr           do not compile simulator for AVR],
58 if test $enable_avr != "no"; then
59     enable_avr="yes"
60 fi,
61 enable_avr="yes")
62 AC_ARG_ENABLE(z80,
63 [  --disable-z80           do not compile simulator for Z80],
64 if test $enable_z80 != "no"; then
65     enable_z80="yes"
66 fi,
67 enable_z80="yes")
68 AC_ARG_ENABLE(hc08,
69 [  --disable-hc08          do not compile simulator for hc08],
70 if test $enable_hc08 != "no"; then
71     enable_hc08="yes"
72 fi,
73 enable_hc08="yes")
74 AC_ARG_ENABLE(xa,
75 [  --enable-xa             compile simulator for XA],
76 if test $enable_xa != "no"; then
77     enable_xa="yes"
78 fi,
79 enable_xa="no")
80 AC_ARG_ENABLE(portmon,
81 [  --enable-serio          compile serio GUI tool (needs curses)],
82 if test $enable_serio != "no"; then
83     enable_serio="yes"
84 fi,
85 enable_serio="no")
86 AC_SUBST(enable_ucsim)
87 AC_SUBST(enable_dlso)
88 AC_SUBST(enable_51)
89 AC_SUBST(enable_avr)
90 AC_SUBST(enable_z80)
91 AC_SUBST(enable_hc08)
92 AC_SUBST(enable_xa)
93 AC_SUBST(enable_serio)
94
95 AC_ARG_ENABLE(statistic,
96 [  --enable-statistic      compile statistical features (slower simulation)],
97 if test $enable_statistic != "no"; then
98    enable_statistic="yes"
99 fi,
100 enable_statistic="no")
101 AC_DEFINE_UNQUOTED(STATISTIC, $enable_statistic)
102
103
104 # Required programs
105 #-------------------
106 AC_PROG_CXX
107 AC_PROG_CXXCPP
108 AC_PROG_INSTALL
109 AC_PROG_RANLIB
110 dnl AC_LANG_CPLUSPLUS
111
112 AC_CHECK_PROG(STRIP, strip, strip, :)
113
114 AC_LIBTOOL_DLOPEN
115 dnl AC_LIBTOOL_WIN32_DLL
116 AC_PROG_LIBTOOL
117 AC_SUBST(LIBTOOL_DEPS)
118
119 AC_PROG_LEX
120 if test ${LEX} = "flex"; then
121         AC_DEFINE(HAVE_FLEX)
122 fi
123 AC_PROG_YACC
124 AC_CHECK_PROG(BISON_PLUS_PLUS, bison++, bison++, :)
125
126
127 AC_LANG_CPLUSPLUS
128
129 # Checking for header files.
130 # ===========================================================================
131
132 if test -d /stuff/include; then
133   CPPFLAGS="$CPPFLAGS -I/stuff/include"
134 fi
135
136 AC_HEADER_STDC
137 AC_CHECK_HEADERS(getopt.h)
138 AC_CHECK_HEADERS(unistd.h)
139
140 AC_CHECK_HEADER(termios.h,
141   AC_DEFINE(HAVE_TERMIOS_H)
142   SERIAL_AVAIL=1,
143   SERIAL_AVAIL=0
144 )
145 AC_SUBST(SERIAL_AVAIL)
146
147 AC_CHECK_HEADER(curses.h,
148   AC_DEFINE(HAVE_CURSES_H)
149   curses_h_ok=yes,
150   curses_h_ok=no
151 )
152
153 ucsim_cv_socket="unknown"
154 AC_CHECK_HEADER(sys/socket.h,
155   AC_DEFINE(HAVE_SYS_SOCKET_H)
156   AC_DEFINE(SOCKET_AVAIL)
157   AC_DEFINE_UNQUOTED(UCSOCKET_T, int)
158   ucsim_cv_socket="<sys/socket.h>"
159 )
160
161 if test $ucsim_cv_socket = unknown; then
162   AC_CHECK_HEADER(winsock2.h,
163     AC_DEFINE(HAVE_WINSOCK2_H)
164     AC_DEFINE(SOCKET_AVAIL)
165     AC_DEFINE_UNQUOTED(UCSOCKET_T, SOCKET)
166     ucsim_cv_socket="<winsock2.h>"
167   )
168 fi
169
170 if test $ucsim_cv_socket != unknown; then
171   AC_EGREP_HEADER(socklen_t,
172     $ucsim_cv_socket,
173     AC_DEFINE_UNQUOTED(SOCKLEN_T, socklen_t),
174     AC_DEFINE_UNQUOTED(SOCKLEN_T, uint))
175 fi
176 AC_DEFINE_UNQUOTED(HEADER_SOCKET, ${ucsim_cv_socket})
177
178 AC_CHECK_HEADER(dlfcn.h)
179 AC_HEADER_DIRENT
180
181 # This must be after CXXCPP
182
183 AC_CACHE_CHECK(which header file defines FD_ macros, ucsim_cv_fd,
184 [ucsim_cv_fd="unknown"
185 AC_EGREP_CPP(yes, [
186 #include <winsock2.h>
187 #ifdef FD_ZERO
188 yes
189 #endif], ucsim_cv_fd="<winsock2.h>")
190 AC_EGREP_CPP(yes, [
191 #include <sys/time.h>
192 #ifdef FD_ZERO
193 yes
194 #endif], ucsim_cv_fd="<sys/time.h>")
195 AC_EGREP_CPP(yes, [
196 #include <sys/types.h>
197 #ifdef FD_ZERO
198 yes
199 #endif], ucsim_cv_fd="<sys/types.h>")
200 AC_EGREP_CPP(yes, [
201 #include <sys/select.h>
202 #ifdef FD_ZERO
203 yes
204 #endif], ucsim_cv_fd="<sys/select.h>")])
205
206 ucsim_cv_header_ok=0
207 if echo $ucsim_cv_fd|grep time >/dev/null 2>&1; then
208 AC_DEFINE(FD_NEED_TIME_H, 1)
209 ucsim_cv_header_ok=1
210 else
211 AC_DEFINE(FD_NEED_TIME_H, 0)
212 fi
213 if echo $ucsim_cv_fd|grep types >/dev/null 2>&1; then
214 AC_DEFINE(FD_NEED_TYPES_H, 1)
215 ucsim_cv_header_ok=1
216 else
217 AC_DEFINE(FD_NEED_TYPES_H, 0)
218 fi
219 if echo $ucsim_cv_fd|grep select >/dev/null 2>&1; then
220 AC_DEFINE(FD_NEED_SELECT_H, 1)
221 ucsim_cv_header_ok=1
222 else
223 AC_DEFINE(FD_NEED_SELECT_H, 0)
224 fi
225 if echo $ucsim_cv_fd|grep winsock2 >/dev/null 2>&1; then
226 AC_DEFINE(FD_NEED_WINSOCK2_H, 1)
227 ucsim_cv_header_ok=1
228 else
229 AC_DEFINE(FD_NEED_WINSOCK2_H, 0)
230 fi
231
232 AC_DEFINE_UNQUOTED(FD_HEADER_OK, ${ucsim_cv_header_ok})
233 AC_DEFINE_UNQUOTED(HEADER_FD, ${ucsim_cv_fd})
234
235
236 # Checking for functions/libs
237 # ===========================================================================
238 if echo $ucsim_cv_socket|grep winsock2 >/dev/null 2>&1; then
239   LIBS="-lwsock32 $LIBS"
240 else
241   AC_CHECK_LIB(socket,socket)
242   AC_CHECK_LIB(nsl,xdr_short)
243 fi
244
245 AC_CHECK_LIB(dl,dlopen,
246 dl_ok="yes"
247 DL="-ldl",
248 dl_ok="no"
249 DL="")
250 AC_SUBST(dl_ok)
251 AC_SUBST(DL)
252
253 #AC_CHECK_LIB(panel,panel_above,
254 #panel_ok="yes"
255 #curses_ok="yes"
256 #CURSES_LIBS="-lpanel -lcurses"
257 #,
258 #panel_ok="no"
259 #AC_CHECK_LIB(curses,nl,
260 #curses_ok="yes"
261 #CURSES_LIBS="-lcurses"
262 #,
263 #curses_ok="no")
264 #,
265 #-lcurses)
266
267 if test $curses_h_ok != yes; then
268   panel_ok="no"
269   curses_ok="no"
270 else
271   AC_CHECK_LIB(panel,panel_above,
272     panel_ok="yes"
273     curses_ok="yes"
274     CURSES_LIBS="-lpanel",
275     panel_ok="no"
276     curses_ok="no"
277   )
278
279   if test $curses_ok != yes; then
280     AC_CHECK_LIB(curses,nl,
281       curses_ok="yes"
282       CURSES_LIBS="-lcurses",
283       curses_ok="no")
284   fi
285
286   if test $curses_ok != yes; then
287     AC_CHECK_LIB(ncurses,nl,
288       curses_ok="yes"
289       CURSES_LIBS="-lncurses",
290       curses_ok="no")
291   fi
292 fi
293
294 AC_SUBST(panel_ok)
295 AC_SUBST(curses_ok)
296 AC_SUBST(CURSES_LIBS)
297
298 AC_FUNC_VPRINTF
299 AC_CHECK_FUNCS(vsnprintf)
300 AC_CHECK_FUNCS(vasprintf)
301 AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
302 AC_CHECK_FUNCS(strchr memcpy)
303 dnl AC_CHECK_FUNCS(getline)
304 dnl AC_CHECK_FUNCS(getdelim)
305 AC_CHECK_FUNCS(fgets)
306 AC_CHECK_FUNCS(yylex)
307
308 AC_CACHE_CHECK(whether scanf knows %a, ucsim_cv_scanf_a,
309 [echo "a b" >conftest.data
310 AC_TRY_RUN([
311 #include <stdio.h>
312 void main(void)
313 {
314   FILE *f;
315   char *a;
316   int  i;
317   if ((f= fopen("conftest.data", "r")) == NULL)
318     exit(1);
319   i= fscanf(f, " %a[a-z] ", &a);
320   fclose(f);
321   if (i == 0)
322     exit(2);
323   if (i == 1)
324     exit(0);
325   exit(3);
326 }],
327 ucsim_cv_scanf_a="yes",
328 ucsim_cv_scanf_a="no",
329 ucsim_cv_scanf_a="unknown")
330 ])
331 if test "$ucsim_cv_scanf_a" = "yes"; then
332   AC_DEFINE(SCANF_A)
333 fi
334
335 AC_CACHE_CHECK(whether getcwd is GNUish, ucsim_cv_getcwd,
336 [AC_TRY_RUN([
337 #include <unistd.h>
338 void main(void)
339 {
340   if ((getcwd(NULL, 0)) == NULL)
341     exit(1);
342   exit(0);
343 }],
344 ucsim_cv_getcwd="yes",
345 ucsim_cv_getcwd="no",
346 ucsim_cv_getcwd="unknown")
347 ])
348 if test "$ucsim_cv_getcwd" = "yes"; then
349   AC_DEFINE(GNU_GETCWD)
350 fi
351
352 AC_DEFUN(ucsim_ACCEPT_LENGTH_T,
353  [AC_CACHE_CHECK([for type of length pointer parameter of accept],
354    ucsim_cv_accept_length_type,
355    [ac_save_CPPFLAGS="$CPPFLAGS"
356     ucsim_cv_accept_length_type=no
357     for ac_val in int size_t socklen_t; do
358       CPPFLAGS="$ac_save_CPPFLAGS -DACCEPT_SOCKLEN_T=$ac_val"
359       AC_TRY_COMPILE([#include <sys/types.h>
360 #include ${ucsim_cv_socket}],
361         [struct sockaddr a; $ac_val len; accept (0, &a, &len);],
362         [ucsim_cv_accept_length_type=$ac_val; break])
363     done
364     CPPFLAGS="$ac_save_CPPFLAGS"])
365   if test "$ucsim_cv_accept_length_type" != no; then
366     AC_DEFINE_UNQUOTED(ACCEPT_SOCKLEN_T, $ucsim_cv_accept_length_type,
367       [Define to be the type of length parameter of accept (without the \*').])
368   fi
369  ]
370 )
371 #'
372
373 ucsim_ACCEPT_LENGTH_T
374
375 # Macro definitions
376 ###################
377
378 # DD_COPT macro checks if the compiler specified as the 1st parameter
379 # supports option specified as the 2nd parameter
380 # For example: DD_COPT(CXX, fPIC)
381
382 AC_DEFUN(DD_COPT, [
383 AC_CACHE_CHECK(whether $$1 accepts -$2,ucsim_cv_$1$2,
384 cat >_test_.c <<EOF
385 #include <stdio.h>
386 int main(void) {return(0);}
387 EOF
388 $$1 -v -$2 -c _test_.c 1>&5 2>&5
389 if test "$?" = "0"; then
390   ucsim_cv_$1$2="yes"
391 else
392   ucsim_cv_$1$2="no"
393 fi
394 rm -f _test_.* a.out)
395 ])
396
397
398 # Checking characteristics of compilers and other programs
399 # --------------------------------------------------------
400
401 # Cross compiling overrides
402 # FIXME
403 if test "$CC" = "i586-mingw32msvc-gcc"; then
404   ac_cv_c_bigendian=no
405   ac_cv_sizeof_char=1
406   ac_cv_sizeof_short=2
407   ac_cv_sizeof_int=4 
408   ac_cv_sizeof_long=4
409   ac_cv_sizeof_long_long=4
410 fi
411
412 if test "$cross_compiling" = "no"
413 then
414     AC_C_BIGENDIAN
415 else
416 #echo "CROSS ENDIAN"
417     if $CXX -v 2>&1|grep "mingw" >/dev/null 2>&1; then
418         ac_cv_c_bigendian=no
419     else
420         : # FIXME
421     fi
422 #echo "CROSS ENDIAN DONE"
423 fi
424
425 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,ucsim_cv_MM,
426 echo "#include <stdio.h>" >_test_.c
427 echo "" >>_test_.c
428 $CXXCPP -v -MM _test_.c 1>&5 2>&5
429 if test "$?" = "0"; then
430   ucsim_cv_MM="-MM"
431 else
432   ucsim_cv_MM="-M"
433 fi
434 rm -f _test_.*)
435 M_OR_MM=$ucsim_cv_MM
436 AC_SUBST(M_OR_MM)
437
438 # This is the first time when CFLAGS are set/modified!!
439
440 DD_COPT(CXX, ggdb)
441 DD_COPT(CXX, gstabs)
442 if test "$ucsim_cv_CXXgstabs" = "yes"; then
443    gopt="-gstabs+ -g3"
444 elif test "$ucsim_cv_CXXggdb" = "yes"; then
445      gopt="-ggdb -g3"
446 else 
447      gopt="-g"
448 fi
449 if test "$CXXFLAGS"x = x ;then
450         CXXFLAGS="$gopt"
451 else
452         CXXFLAGS="$CXXFLAGS $gopt"
453 fi
454
455 DD_COPT(CXX, pipe)
456 if test "$ucsim_cv_CXXpipe" = "yes"; then
457   CXXFLAGS="$CXXFLAGS -pipe"
458 fi
459
460 PICOPT=""
461 SHAREDLIB="no"
462 DD_COPT(CXX, fPIC)
463 if test "$ucsim_cv_CXXfPIC" = "yes"; then
464     PICOPT="-fPIC"
465 else
466     DD_COPT(CXX, fpic)
467     if test "$ucsim_cv_CXXfpic" = "yes"; then
468         PICOPT="-fpic"
469     fi
470 fi
471 if test "$PICOPT"x != "x"; then
472     SHAREDLIB="yes"
473 fi
474 # If this is Cygwin neither use Position Independant Code
475 # nor build .so
476 # Quick + dirty by Bernhard
477 # FIXME
478 if $CXX --version 2>&1 | grep -i cygming 1>&5 2>&5 || $CXX --version 2>&1 | grep -i cygwin 1>&5 2>&5; then
479     PICOPT=""
480     SHAREDLIB="no"
481 fi
482 AC_SUBST(SHAREDLIB)
483 AC_SUBST(PICOPT)
484
485 dlso_ok="no"
486 if test $SHAREDLIB = "yes" -a $dl_ok = "yes" -a $enable_dlso = "yes"; then
487     dlso_ok="yes"
488 fi
489 AC_SUBST(dlso_ok)
490
491 # Checks for typedefs, structures, and compiler characteristics.
492 # ===========================================================================
493
494 AC_TYPE_SIGNAL
495 if test "$cross_compiling" = "no"; then
496 AC_CHECK_SIZEOF(char)
497 AC_CHECK_SIZEOF(short)
498 AC_CHECK_SIZEOF(int)
499 AC_CHECK_SIZEOF(long)
500 AC_CHECK_SIZEOF(long long)
501 else
502     if $CXX -v 2>&1|grep "mingw" >/dev/null 2>&1; then
503         ac_cv_sizeof_char=1
504         ac_cv_sizeof_short=2
505         ac_cv_sizeof_int=4 
506         ac_cv_sizeof_long=4
507         ac_cv_sizeof_long_long=4
508     else
509         : # FIXME
510     fi
511 #echo
512 fi
513
514 type_name()
515 {
516     if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then
517         echo "char"
518         exit
519     fi
520     if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then
521         echo "short"
522         exit
523     fi
524     if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then
525         echo "int"
526         exit
527     fi
528     if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then
529         echo "long"
530         exit
531     fi
532     if expr "$ac_cv_sizeof_long_long" '>=' "$1" >/dev/null; then
533         echo "long long"
534         exit
535     fi
536     echo "long long"
537 }
538
539 AC_MSG_CHECKING(type name for byte)
540 TYPE_BYTE=`type_name 1`
541 AC_MSG_RESULT($TYPE_BYTE)
542 AC_MSG_CHECKING(type name for word)
543 TYPE_WORD=`type_name 2`
544 AC_MSG_RESULT($TYPE_WORD)
545 AC_MSG_CHECKING(type name for dword)
546 TYPE_DWORD=`type_name 4`
547 AC_MSG_RESULT($TYPE_DWORD)
548 AC_DEFINE_UNQUOTED(TYPE_BYTE, $TYPE_BYTE)
549 AC_DEFINE_UNQUOTED(TYPE_WORD, $TYPE_WORD)
550 AC_DEFINE_UNQUOTED(TYPE_DWORD, $TYPE_DWORD)
551
552 if echo $TYPE_DWORD|grep short >/dev/null; then
553     A="h"
554 elif echo $TYPE_DWORD|grep long >/dev/null; then
555     A="l"
556 else
557     A=""
558 fi
559
560 if echo $TYPE_WORD|grep short >/dev/null; then M="h"
561 elif echo $TYPE_WORD|grep long >/dev/null; then M="l"
562 else M=""
563 fi
564
565 AC_DEFINE_UNQUOTED(_A_, "${A}")
566 AC_DEFINE_UNQUOTED(_M_, "${M}")
567
568 # Generating output files
569 # ===========================================================================
570
571 AC_OUTPUT(Makefile
572 main.mk:main_in.mk
573 packages.mk:packages_in.mk
574 sim.src/Makefile
575 cmd.src/Makefile
576 s51.src/Makefile
577 avr.src/Makefile
578 z80.src/Makefile
579 hc08.src/Makefile
580 xa.src/Makefile
581 gui.src/Makefile
582 gui.src/serio.src/Makefile
583 doc/Makefile
584 )
585
586 #gui.src/portmon.src/Makefile
587
588
589 # End of configure/configure.in