]> rtime.felk.cvut.cz Git - orte.git/commitdiff
Execute test for target endianness only if "endian.h" is missing or unusable.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 12 Sep 2013 16:12:52 +0000 (18:12 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 12 Sep 2013 16:12:52 +0000 (18:12 +0200)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
configure.ac

index 04c0dc9d44e6c905b68b3e576ed8236c57559e33..4adef0fd69c39bb64d231e2c065362082c19960b 100644 (file)
@@ -236,7 +236,39 @@ AC_SUBST(INCLUDES)
 
 ###############################
 # Checks for typedefs, structures, and compiler characteristics.
-AC_C_BIGENDIAN
+need_endian_test=no
+AC_CHECK_HEADERS([endian.h], [], [],[])
+if test "$ac_cv_header_endian_h" == 'yes' ; then
+    AC_MSG_CHECKING([whether endian can be determined from endian.h])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <endian.h>], [
+                        unsigned int a=__BYTE_ORDER;
+                        unsigned int b=__BIG_ENDIAN;
+                        unsigned int c=__LITTLE_ENDIAN;])],
+                      [AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
+                      need_endian_test=yes
+                      ])
+else
+  need_endian_test=yes
+fi
+
+if test "$need_endian_test" == 'yes' ; then
+  AC_C_BIGENDIAN
+fi
+
+AH_BOTTOM([
+#ifdef HAVE_ENDIAN_H
+  #include <endian.h>
+  #ifdef __BYTE_ORDER
+    #if __BYTE_ORDER == __BIG_ENDIAN
+      #define WORDS_BIGENDIAN 1
+    #endif
+    #if __BYTE_ORDER == __LITTLE_ENDIAN
+      #undef WORDS_BIGENDIAN
+    #endif
+  #endif
+#endif
+])
+
 AC_C_CONST
 AC_C_INLINE