configure: add endian check
[fio.git] / configure
index e45ae394256a8eca2ea3f77f25336fd4e4c42783..795c22037325b44f79cf1fcb817240de3724eaa3 100755 (executable)
--- a/configure
+++ b/configure
@@ -238,8 +238,25 @@ fi
 
 cc="${CC-${cross_prefix}gcc}"
 
 
 cc="${CC-${cross_prefix}gcc}"
 
+##########################################
+# check endianness
+bigendian="no"
+cat > $TMPC <<EOF
+#include <inttypes.h>
+int main(void)
+{
+  volatile uint32_t i=0x01234567;
+  return (*((uint8_t*)(&i))) == 0x67;
+}
+EOF
+if compile_prog "" "" "endian"; then
+  $TMPE && bigendian="yes"
+fi
+
+
 echo "Operating system              $targetos"
 echo "CPU                           $cpu"
 echo "Operating system              $targetos"
 echo "CPU                           $cpu"
+echo "Big endian                    $bigendian"
 echo "Compiler                      $cc"
 echo
 
 echo "Compiler                      $cc"
 echo
 
@@ -783,6 +800,11 @@ else
   echo "Unknown wordsize!"
   exit 1
 fi
   echo "Unknown wordsize!"
   exit 1
 fi
+if test "$bigendian" = "yes" ; then
+  echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
+else
+  echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
+fi
 if test "$libaio" = "yes" ; then
   echo "CONFIG_LIBAIO=y" >> $config_host_mak
 fi
 if test "$libaio" = "yes" ; then
   echo "CONFIG_LIBAIO=y" >> $config_host_mak
 fi