5 dnl check if this computer is little or big-endian
6 dnl if we can figure it out at compile-time then don't define the cpp symbol
7 dnl otherwise test for it and define it. also allow options for overriding
8 dnl it when cross-compiling
10 AC_DEFUN([OPENAFS_CHECK_BIGENDIAN], [
11 AC_ARG_ENABLE(bigendian,
12 [ --enable-bigendian the target is big endian],
13 openafs_cv_c_bigendian=yes)
14 AC_ARG_ENABLE(littleendian,
15 [ --enable-littleendian the target is little endian],
16 openafs_cv_c_bigendian=no)
17 AC_CACHE_CHECK(whether byte order is known at compile time,
18 openafs_cv_c_bigendian_compile,
20 #include <sys/types.h>
21 #include <sys/param.h>],[
22 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
24 #endif], openafs_cv_c_bigendian_compile=yes, openafs_cv_c_bigendian_compile=no)])
25 AC_CACHE_CHECK(whether byte ordering is bigendian, openafs_cv_c_bigendian,[
26 if test "$openafs_cv_c_bigendian_compile" = "yes"; then
28 #include <sys/types.h>
29 #include <sys/param.h>],[
30 #if BYTE_ORDER != BIG_ENDIAN
32 #endif], openafs_cv_c_bigendian=yes, openafs_cv_c_bigendian=no)
35 /* Are we little or big endian? From Harbison&Steele. */
39 char c[sizeof (long)];
42 exit (u.c[sizeof (long) - 1] == 1);
43 }], openafs_cv_c_bigendian=no, openafs_cv_c_bigendian=yes,
44 AC_MSG_ERROR([specify either --enable-bigendian or --enable-littleendian]))
47 if test "$openafs_cv_c_bigendian" = "yes"; then
48 AC_DEFINE(AUTOCONF_FOUND_BIGENDIAN, 1, [define if target is big endian])dnl
50 if test "$openafs_cv_c_bigendian_compile" = "yes"; then
51 AC_DEFINE(ENDIANESS_IN_SYS_PARAM_H, 1, [define if sys/param.h defines the endiness])dnl