* sim/ucsim/cmd.src/cmdmem.cc, sim/ucsim/cmd.src/mem.cc:
[fw/sdcc] / sim / ucsim / configure.in
index 17ff5a39b5cd7a568cb26c1357c3bc747e0f8573..c2278950625eb66080fefc05c1640c8d8137560b 100644 (file)
@@ -8,7 +8,7 @@ AC_PROG_AWK
 
 AC_MSG_CHECKING(version of the package)
 if test -f ${srcdir}/.version; then
-  VERSION=`cat ${srcdir}/.version`
+  { read VERSION; } < ${srcdir}/.version
   AC_MSG_RESULT($VERSION)
 else
   VERSION="0.0.0"
@@ -379,7 +379,6 @@ ucsim_ACCEPT_LENGTH_T
 AC_DEFUN(DD_COPT, [
 AC_CACHE_CHECK(whether $$1 accepts -$2,ucsim_cv_$1$2,
 cat >_test_.c <<EOF
-#include <stdio.h>
 int main(void) {return(0);}
 EOF
 $$1 -v -$2 -c _test_.c 1>&5 2>&5
@@ -391,6 +390,30 @@ fi
 rm -f _test_.* a.out)
 ])
 
+# DD_COPT_NO_IGNORE macro checks if the compiler specified as the
+# 1st parameter supports and doesn't ignore option specified as the
+# 2nd parameter
+# For example: DD_COPT_NO_IGNORE(CXX, fPIC)
+
+AC_DEFUN(DD_COPT_NO_IGNORE, [
+AC_CACHE_CHECK(whether $$1 accepts and doesn't ignore -$2,ucsim_cv_$1$2,
+cat >_test_.c <<EOF
+int main(void) {return(0);}
+EOF
+ucsim_cv_$1$2=$($$1 -v -$2 -c _test_.c 2>&1 1>&5)
+if test "$?" = "0"; then
+  expr "$ucsim_cv_$1$2" : '.*'-$2'.*ignored' 1>&5 2>&5
+  if test "$?" = "0"; then
+    ucsim_cv_$1$2="no"
+  else
+    ucsim_cv_$1$2="yes"
+  fi
+else
+  ucsim_cv_$1$2="no"
+fi
+rm -f _test_.* a.out)
+])
+
 
 # Checking characteristics of compilers and other programs
 # --------------------------------------------------------
@@ -406,18 +429,77 @@ if test "$CC" = "i586-mingw32msvc-gcc"; then
   ac_cv_sizeof_long_long=4
 fi
 
-if test "$cross_compiling" = "no"
-then
-    AC_C_BIGENDIAN
-else
-#echo "CROSS ENDIAN"
-    if $CXX -v 2>&1|grep "mingw" >/dev/null 2>&1; then
-        ac_cv_c_bigendian=no
-    else
-        : # FIXME
-    fi
-#echo "CROSS ENDIAN DONE"
+# SDCC_BUILD_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
+# -------------------------------------------------------------------------
+AC_DEFUN([SDCC_BUILD_BIGENDIAN],
+[AC_CACHE_CHECK(whether host machine byte ordering is bigendian, sdcc_cv_build_bigendian,
+[# See if sys/param.h defines the BYTE_ORDER macro.
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
+#include <sys/param.h>
+],
+[#if  ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \
+       && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN)
+ bogus endian macros
+#endif
+])],
+[# It does; now see whether it defined to BIG_ENDIAN or not.
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
+#include <sys/param.h>
+], [#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
+])], [sdcc_cv_build_bigendian=yes], [sdcc_cv_build_bigendian=no])],
+[# It does not; compile a test program.
+AC_RUN_IFELSE(
+[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
+  /* Are we little or big endian?  From Harbison&Steele.  */
+  union
+  {
+    long int l;
+    char c[sizeof (long int)];
+  } u;
+  u.l = 1;
+  return u.c[sizeof (long int) - 1] == 1;
+]])],
+             [sdcc_cv_build_bigendian=no],
+             [sdcc_cv_build_bigendian=yes],
+[# try to guess the endianness by grepping values into an object file
+  sdcc_cv_build_bigendian=unknown
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
+short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]],
+[[ _ascii (); _ebcdic (); ]])],
+[if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
+  sdcc_cv_build_bigendian=yes
 fi
+if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+  if test "$sdcc_cv_build_bigendian" = unknown; then
+    sdcc_cv_build_bigendian=no
+  else
+    # finding both strings is unlikely to happen, but who knows?
+    sdcc_cv_build_bigendian=unknown
+  fi
+fi])])])])
+case $sdcc_cv_build_bigendian in
+  yes)
+    m4_default([$1],
+      [AC_DEFINE([BUILD_WORDS_BIGENDIAN], 1,
+       [Define to 1 if your processor stores words with the most significant
+        byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;;
+  no)
+    $2 ;;
+  *)
+    m4_default([$3],
+      [AC_MSG_ERROR([unknown endianness
+presetting sdcc_cv_build_bigendian=no (or yes) will help])]) ;;
+esac
+])# SDCC_BUILD_BIGENDIAN
+
+SDCC_BUILD_BIGENDIAN
 
 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,ucsim_cv_MM,
 echo "#include <stdio.h>" >_test_.c
@@ -456,11 +538,11 @@ fi
 
 PICOPT=""
 SHAREDLIB="no"
-DD_COPT(CXX, fPIC)
+DD_COPT_NO_IGNORE(CXX, fPIC)
 if test "$ucsim_cv_CXXfPIC" = "yes"; then
     PICOPT="-fPIC"
 else
-    DD_COPT(CXX, fpic)
+    DD_COPT_NO_IGNORE(CXX, fpic)
     if test "$ucsim_cv_CXXfpic" = "yes"; then
         PICOPT="-fpic"
     fi
@@ -468,14 +550,6 @@ fi
 if test "$PICOPT"x != "x"; then
     SHAREDLIB="yes"
 fi
-# If this is Cygwin neither use Position Independant Code
-# nor build .so
-# Quick + dirty by Bernhard
-# FIXME
-if $CXX --version 2>&1 | grep -i cygming 1>&5 2>&5 || $CXX --version 2>&1 | grep -i cygwin 1>&5 2>&5; then
-    PICOPT=""
-    SHAREDLIB="no"
-fi
 AC_SUBST(SHAREDLIB)
 AC_SUBST(PICOPT)