changeset 6913:d5056a166cce

endian autodetection by Bertrand + Michael, tested on x86, PPC, sparc, alpha
author atmos4
date Mon, 05 Aug 2002 01:31:47 +0000
parents 5ddd609550d5
children d882c7063e6d
files configure
diffstat 1 files changed, 35 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Mon Aug 05 01:14:14 2002 +0000
+++ b/configure	Mon Aug 05 01:31:47 2002 +0000
@@ -165,6 +165,8 @@
   --disable-mpdvdkit     Disable mpdvdkit support [autodetect]
   --disable-css          Disable oldstyle libcss DVD support [autodetect]
   --disable-cdparanoia   Disable cdparanoia support [autodetect]
+  --disable-big-endian   Force byte order to little endian [autodetect]
+  --enable-big-endian    Force byte order to big endian [autodetect]
   
 Video:
   --enable-gl            build with OpenGL render support [autodetect]
@@ -341,6 +343,7 @@
       arm*) host_arch=arm ;;
       s390) host_arch=s390 ;;
       s390x) host_arch=s390x ;;
+      mips) host_arch=mips ;;
       *) host_arch=UNKNOWN ;;
     esac
     ;;
@@ -572,7 +575,6 @@
   i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
   _def_arch="#define ARCH_X86 1"
   _target_arch="TARGET_ARCH_X86 = yes"
-  _def_words_endian="#undef WORDS_BIGENDIAN"
 
   case "$pvendor" in
   AuthenticAMD)
@@ -741,7 +743,6 @@
   ia64)
     _def_arch='#define ARCH_IA64 1'
     _target_arch='TARGET_ARCH_IA64 = yes'
-    _def_words_endian='#undef WORDS_BIGENDIAN'
     iproc='ia64'
     proc=''
     _march=''
@@ -751,7 +752,6 @@
   x86_64)
     _def_arch='#define ARCH_X86_64 1'
     _target_arch='TARGET_ARCH_X86_64 = yes'
-    _def_words_endian='#undef WORDS_BIGENDIAN'
     iproc='x86_64'
     proc=''
     _march=''
@@ -761,7 +761,6 @@
   sparc)
     _def_arch='#define ARCH_SPARC 1'
     _target_arch='TARGET_ARCH_SPARC = yes'
-    _def_words_endian='#define WORDS_BIGENDIAN 1'
     iproc='sparc'
     proc='v8'
     _march=''
@@ -771,7 +770,6 @@
   arm)
     _def_arch='#define ARCH_ARM 1'
     _target_arch='TARGET_ARCH_ARM = yes'
-    _def_words_endian='#undef WORDS_BIGENDIAN'
     iproc=arm
     proc=''
     _march=''
@@ -781,7 +779,6 @@
   ppc)
     _def_arch='#define ARCH_PPC 1'
     _target_arch='TARGET_ARCH_PPC = yes'
-    _def_words_endian='#define WORDS_BIGENDIAN 1'
     iproc='ppc'
     proc=''
     _march=''
@@ -796,7 +793,6 @@
   alpha)
     _def_arch='#define ARCH_ALPHA 1'
     _target_arch='TARGET_ARCH_ALPHA = yes'
-    _def_words_endian='#undef WORDS_BIGENDIAN'
     iproc='alpha'
     _march=''
     echocheck "GCC & CPU optimization abilities"
@@ -813,7 +809,6 @@
   mips)
     _def_arch='#define ARCH_SGI_MIPS 1'
     _target_arch='TARGET_ARCH_SGI_MIPS = yes'
-    _def_words_endian='#define WORDS_BIGENDIAN 1'
     iproc='sgi-mips'
     proc=''
     _march=''
@@ -823,7 +818,6 @@
   s390)
     _def_arch='#define ARCH_S390 1'
     _target_arch='TARGET_ARCH_S390 = yes'
-    _def_words_endian='#define WORDS_BIGENDIAN 1'
     iproc='390'
     proc=''
     _march=''
@@ -833,7 +827,6 @@
   s390x)
     _def_arch='#define ARCH_S390X 1'
     _target_arch='TARGET_ARCH_S390X = yes'
-    _def_words_endian='#define WORDS_BIGENDIAN 1'
     iproc='390x'
     proc=''
     _march=''
@@ -971,6 +964,7 @@
 _sighandler=yes
 _libdv=auto
 _cdparanoia=auto
+_big_endian=auto
 
 for ac_option do
   case "$ac_option" in
@@ -1129,6 +1123,8 @@
   --disable-linux-devfs)	_linux_devfs=no	;;
   --enable-cdparanoia)	_cdparanoia=yes	;;
   --disable-cdparanoia)	_cdparanoia=no	;;
+  --enable-big-endian)  _big_endian=yes ;;
+  --disable-big-endian) _big_endian=no  ;;
 
   --enable-dga) _dga=auto ;; # as we don't know if it's 1 or 2
   --enable-dga=*) _dga=`echo $ac_option | cut -d '=' -f 2` ;;
@@ -3846,7 +3842,34 @@
 fi
 echores "$_streaming"
 
-
+# endian testing
+echocheck "byte order"
+if test "$_big_endian" = auto ; then
+  cat > $TMPC <<EOF
+#include <inttypes.h>
+int main(void) { 
+    volatile uint32_t i=0x01234567;
+    return (*((uint8_t*)(&i))) == 0x67;
+}
+EOF
+  if cc_check ; then 
+    if $TMPO ; then 
+      _big_endian=yes
+    else
+      _big_endian=no
+    fi
+  else
+    echo -n "failed to autodetect byte order, defaulting to "
+  fi
+fi
+if test "$_big_endian" = yes ; then
+  _byte_order='Big Endian'
+  _def_words_endian='#define WORDS_BIGENDIAN 1'
+else
+  _byte_order='Little Endian'
+  _def_words_endian='#undef WORDS_BIGENDIAN'
+fi
+echores "$_byte_order"
 
 # --------------- GUI specific tests begin -------------------
 echocheck "GUI"
@@ -4657,6 +4680,7 @@
   Data directory: $_datadir
   Config direct.: $_confdir
 
+  Byte order: $_byte_order
   Optimizing for: $_optimizing
   
   Enabled optional drivers: