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