Version 0.3.2-pre1
[fw/sdcc] / sim / ucsim / configure.in
index f40b6138a65804ad9d3aa6ac1de574eee4a818ba..cb8ade102ad14bb3e4d24a0bcf0f6d224422c1c2 100644 (file)
@@ -46,95 +46,70 @@ AC_HEADER_STDC
 AC_CHECK_HEADERS(getopt.h)
 AC_CHECK_HEADERS(unistd.h)
 AC_CHECK_HEADER(sys/socket.h,
-  AC_DEFINE(SOCKET_AVAIL)
-  AC_DEFINE(HAVE_SYS_SOCKET_H))
+    AC_DEFINE(SOCKET_AVAIL)
+    AC_DEFINE(HAVE_SYS_SOCKET_H)
+    AC_EGREP_HEADER(socklen_t,
+                   sys/socket.h,
+                   AC_DEFINE_UNQUOTED(SOCKLEN_T, socklen_t),
+                   AC_DEFINE_UNQUOTED(SOCKLEN_T, uint))
+)
+AC_CHECK_HEADER(dlfcn.h)
 AC_HEADER_DIRENT
 
 # This must be after CXXCPP
 
-AC_CACHE_CHECK(which header file defines FD_ macros, s51_cv_fd,
-[s51_cv_fd="unknown"
+AC_CACHE_CHECK(which header file defines FD_ macros, ucsim_cv_fd,
+[ucsim_cv_fd="unknown"
 AC_EGREP_CPP(yes, [
 #include <sys/time.h>
 #ifdef FD_ZERO
 yes
-#endif], s51_cv_fd="<sys/time.h>")
+#endif], ucsim_cv_fd="<sys/time.h>")
 AC_EGREP_CPP(yes, [
 #include <sys/types.h>
 #ifdef FD_ZERO
 yes
-#endif], s51_cv_fd="<sys/types.h>")
+#endif], ucsim_cv_fd="<sys/types.h>")
 AC_EGREP_CPP(yes, [
 #include <sys/select.h>
 #ifdef FD_ZERO
 yes
-#endif], s51_cv_fd="<sys/types.h>")])
+#endif], ucsim_cv_fd="<sys/types.h>")])
 
 AC_DEFINE(FD_HEADER_OK, 0)
-if echo $s51_cv_fd|grep time >/dev/null 2>&1; then
+if echo $ucsim_cv_fd|grep time >/dev/null 2>&1; then
 AC_DEFINE(FD_NEED_TIME_H, 1)
 AC_DEFINE(FD_HEADER_OK, 1)
 else
 AC_DEFINE(FD_NEED_TIME_H, 0)
 fi
-if echo $s51_cv_fd|grep types >/dev/null 2>&1; then
+if echo $ucsim_cv_fd|grep types >/dev/null 2>&1; then
 AC_DEFINE(FD_NEED_TYPES_H, 1)
 AC_DEFINE(FD_HEADER_OK, 1)
 else
 AC_DEFINE(FD_NEED_TYPES_H, 0)
 fi
-if echo $s51_cv_fd|grep select >/dev/null 2>&1; then
+if echo $ucsim_cv_fd|grep select >/dev/null 2>&1; then
 AC_DEFINE(FD_NEED_SELECT_H, 1)
 AC_DEFINE(FD_HEADER_OK, 1)
 else
 AC_DEFINE(FD_NEED_SELECT_H, 0)
 fi
 
-AC_DEFINE_UNQUOTED(HEADER_FD, ${s51_cv_fd})
+AC_DEFINE_UNQUOTED(HEADER_FD, ${ucsim_cv_fd})
 
 
 # Checking for functions/libs
 # ===========================================================================
-
-AC_DEFUN(AC_CHECK_FUNC_NOCACHE,
-[AC_MSG_CHECKING([for $1])
-AC_TRY_LINK(
-dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
-dnl which includes <sys/select.h> which contains a prototype for
-dnl select.  Similarly for bzero.
-[/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $1(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char $1();
-], [
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$1) || defined (__stub___$1)
-choke me
-#else
-$1();
-#endif
-], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")
-if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then
-  AC_MSG_RESULT(yes)
-  ifelse([$2], , :, [$2])
-else
-  AC_MSG_RESULT(no)
-ifelse([$3], , , [$3
-])dnl
-fi
-])
-
 AC_CHECK_LIB(socket,socket)
 AC_CHECK_LIB(nsl,xdr_short)
+AC_CHECK_LIB(dl,dlopen,
+dl_ok="yes"
+DL="-ldl",
+dl_ok="no"
+DL="")
+AC_SUBST(dl_ok)
+AC_SUBST(DL)
 AC_CHECK_LIB(panel,panel_above,
 panel_ok="yes"
 curses_ok="yes"
@@ -153,22 +128,15 @@ AC_SUBST(curses_ok)
 AC_SUBST(CURSES_LIBS)
 
 AC_FUNC_VPRINTF
-dnl Do not cache the result of the vasprintf test.
-dnl This is because vasprintf is defined in the C++ runtime 
-dnl for egcs, but not in the C runtime. Thus, caching the result
-dnl of this test (which is done with C++) will cause later C
-dnl based tests to falsely conclude that vasprintf is available
-dnl to C programs.
-dnl It's a bloody stupid function anyway. 
-AC_CHECK_FUNC_NOCACHE(vasprintf)
+AC_CHECK_FUNCS(vsnprintf vasprintf)
 AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
-AC_CHECK_FUNCS(vsnprintf strchr memcpy)
+AC_CHECK_FUNCS(strchr memcpy)
 dnl AC_CHECK_FUNCS(getline)
 dnl AC_CHECK_FUNCS(getdelim)
 AC_CHECK_FUNCS(fgets)
 AC_CHECK_FUNCS(yylex)
 
-AC_CACHE_CHECK(whether scanf knows %a, s51_cv_scanf_a,
+AC_CACHE_CHECK(whether scanf knows %a, ucsim_cv_scanf_a,
 [echo "a b" >conftest.data
 AC_TRY_RUN([
 #include <stdio.h>
@@ -187,15 +155,15 @@ void main(void)
     exit(0);
   exit(3);
 }],
-s51_cv_scanf_a="yes",
-s51_cv_scanf_a="no",
-s51_cv_scanf_a="unknown")
+ucsim_cv_scanf_a="yes",
+ucsim_cv_scanf_a="no",
+ucsim_cv_scanf_a="unknown")
 ])
-if test "$s51_cv_scanf_a" = "yes"; then
+if test "$ucsim_cv_scanf_a" = "yes"; then
   AC_DEFINE(SCANF_A)
 fi
 
-AC_CACHE_CHECK(whether getcwd is GNUish, s51_cv_getcwd,
+AC_CACHE_CHECK(whether getcwd is GNUish, ucsim_cv_getcwd,
 [AC_TRY_RUN([
 #include <unistd.h>
 void main(void)
@@ -204,33 +172,56 @@ void main(void)
     exit(1);
   exit(0);
 }],
-s51_cv_getcwd="yes",
-s51_cv_getcwd="no",
-s51_cv_getcwd="unknown")
+ucsim_cv_getcwd="yes",
+ucsim_cv_getcwd="no",
+ucsim_cv_getcwd="unknown")
 ])
-if test "$s51_cv_getcwd" = "yes"; then
+if test "$ucsim_cv_getcwd" = "yes"; then
   AC_DEFINE(GNU_GETCWD)
 fi
 
+AC_DEFUN(ucsim_ACCEPT_LENGTH_T,
+ [AC_CACHE_CHECK([for type of length pointer parameter of accept],
+   ucsim_cv_accept_length_type,
+   [ac_save_CPPFLAGS="$CPPFLAGS"
+    ucsim_cv_accept_length_type=no
+    for ac_val in int size_t socklen_t; do
+      CPPFLAGS="$ac_save_CPPFLAGS -DACCEPT_SOCKLEN_T=$ac_val"
+      AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>],
+        [struct sockaddr a; $ac_val len; accept (0, &a, &len);],
+        [ucsim_cv_accept_length_type=$ac_val; break])
+    done
+    CPPFLAGS="$ac_save_CPPFLAGS"])
+
+  if test $ucsim_cv_accept_length_type != no; then
+    AC_DEFINE_UNQUOTED(ACCEPT_SOCKLEN_T, $ucsim_cv_accept_length_type,
+      [Define to be the type of length parameter of accept (without the \*').])
+  fi
+ ]
+)
+#'
+
+ucsim_ACCEPT_LENGTH_T
 
 # Macro definitions
 ###################
 
 # DD_COPT macro checks if the compiler specified as the 1st parameter
 # supports option specified as the 2nd parameter
-# For example: DD_CPORT(CXX, fPIC)
+# For example: DD_COPT(CXX, fPIC)
 
 AC_DEFUN(DD_COPT, [
-AC_CACHE_CHECK(whether $$1 accepts -$2,s51_cv_$1$2,
+AC_CACHE_CHECK(whether $$1 accepts -$2,ucsim_cv_$1$2,
 cat >_test_.c <<EOF
 #include <stdio.h>
 void main(void) {}
 EOF
 $$1 -v -$2 -c _test_.c 1>&5 2>&5
 if test "$?" = "0"; then
-  s51_cv_$1$2="yes"
+  ucsim_cv_$1$2="yes"
 else
-  s51_cv_$1$2="no"
+  ucsim_cv_$1$2="no"
 fi
 rm -f _test_.* a.out)
 ])
@@ -239,23 +230,23 @@ rm -f _test_.* a.out)
 # Checking characteristics of compilers and other programs
 # --------------------------------------------------------
 AC_C_BIGENDIAN
-AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,s51_cv_MM,
+AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,ucsim_cv_MM,
 echo "#include <stdio.h>" >_test_.c
 echo "" >>_test_.c
 $CXXCPP -v -MM _test_.c 1>&5 2>&5
 if test "$?" = "0"; then
-  s51_cv_MM="-MM"
+  ucsim_cv_MM="-MM"
 else
-  s51_cv_MM="-M"
+  ucsim_cv_MM="-M"
 fi
 rm -f _test_.*)
-M_OR_MM=$s51_cv_MM
+M_OR_MM=$ucsim_cv_MM
 AC_SUBST(M_OR_MM)
 
 # This is the first time when CFLAGS are set/modified!!
 
 DD_COPT(CXX, ggdb)
-if test "$s51_cv_CXXggdb" = "yes"; then
+if test "$ucsim_cv_CXXggdb" = "yes"; then
     if test "$CXXFLAGS"x = x ;then
        CXXFLAGS="-ggdb -O"
     else
@@ -264,10 +255,27 @@ if test "$s51_cv_CXXggdb" = "yes"; then
 fi
 
 DD_COPT(CXX, pipe)
-if test "$s51_cv_CXXpipe" = "yes"; then
+if test "$ucsim_cv_CXXpipe" = "yes"; then
   CXXFLAGS="$CXXFLAGS -pipe"
 fi
 
+PICOPT=""
+SHAREDLIB="no"
+DD_COPT(CXX, fPIC)
+if test "$ucsim_cv_CXXfPIC" = "yes"; then
+    PICOPT="-fPIC"
+else
+    DD_COPT(CXX, fpic)
+    if test "$ucsim_cv_CXXfpic" = "yes"; then
+       PICOPT="-fpic"
+    fi
+fi
+if test "$PICOPT"x != "x"; then
+    SHAREDLIB="yes"
+fi
+AC_SUBST(SHAREDLIB)
+AC_SUBST(PICOPT)
+
 
 # Checks for typedefs, structures, and compiler characteristics.
 # ===========================================================================
@@ -328,9 +336,10 @@ avr.src/Makefile
 z80.src/Makefile
 gui.src/Makefile
 gui.src/serio.src/Makefile
-gui.src/portmon.src/Makefile
 doc/Makefile
 )
 
+#gui.src/portmon.src/Makefile
+
 
 # End of configure/configure.in