2000-01-09 20:58:00 +00:00
|
|
|
dnl
|
2008-05-07 13:39:42 +00:00
|
|
|
dnl $Id: krb-bigendian.m4 15456 2005-06-16 21:04:43Z lha $
|
2000-01-09 20:58:00 +00:00
|
|
|
dnl
|
|
|
|
|
|
|
|
dnl check if this computer is little or big-endian
|
|
|
|
dnl if we can figure it out at compile-time then don't define the cpp symbol
|
|
|
|
dnl otherwise test for it and define it. also allow options for overriding
|
|
|
|
dnl it when cross-compiling
|
|
|
|
|
2004-04-03 21:22:55 +00:00
|
|
|
AC_DEFUN([KRB_C_BIGENDIAN], [
|
2000-01-09 20:58:00 +00:00
|
|
|
AC_ARG_ENABLE(bigendian,
|
2008-05-07 13:39:42 +00:00
|
|
|
AS_HELP_STRING([--enable-bigendian],[the target is big endian]),
|
2000-01-09 20:58:00 +00:00
|
|
|
krb_cv_c_bigendian=yes)
|
|
|
|
AC_ARG_ENABLE(littleendian,
|
2008-05-07 13:39:42 +00:00
|
|
|
AS_HELP_STRING([--enable-littleendian],[the target is little endian]),
|
2000-01-09 20:58:00 +00:00
|
|
|
krb_cv_c_bigendian=no)
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_CACHE_CHECK([whether byte order is known at compile time],
|
2000-01-09 20:58:00 +00:00
|
|
|
krb_cv_c_bigendian_compile,
|
2008-05-07 13:39:42 +00:00
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
2000-01-09 20:58:00 +00:00
|
|
|
#include <sys/types.h>
|
2008-05-07 13:39:42 +00:00
|
|
|
#include <sys/param.h>
|
2000-01-09 20:58:00 +00:00
|
|
|
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
|
|
|
|
bogus endian macros
|
2008-05-07 13:39:42 +00:00
|
|
|
#endif]])],[krb_cv_c_bigendian_compile=yes],[krb_cv_c_bigendian_compile=no])])
|
2001-02-13 16:46:19 +00:00
|
|
|
AC_CACHE_CHECK(whether byte ordering is bigendian, krb_cv_c_bigendian,[
|
|
|
|
if test "$krb_cv_c_bigendian_compile" = "yes"; then
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
2000-01-09 20:58:00 +00:00
|
|
|
#include <sys/types.h>
|
2008-05-07 13:39:42 +00:00
|
|
|
#include <sys/param.h>
|
2000-01-09 20:58:00 +00:00
|
|
|
#if BYTE_ORDER != BIG_ENDIAN
|
|
|
|
not big endian
|
2008-05-07 13:39:42 +00:00
|
|
|
#endif]])],[krb_cv_c_bigendian=yes],[krb_cv_c_bigendian=no])
|
2001-02-13 16:46:19 +00:00
|
|
|
else
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[main (int argc, char **argv) {
|
2000-01-09 20:58:00 +00:00
|
|
|
/* Are we little or big endian? From Harbison&Steele. */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
long l;
|
|
|
|
char c[sizeof (long)];
|
2001-02-13 16:46:19 +00:00
|
|
|
} u;
|
|
|
|
u.l = 1;
|
|
|
|
exit (u.c[sizeof (long) - 1] == 1);
|
2008-05-07 13:39:42 +00:00
|
|
|
}]])],[krb_cv_c_bigendian=no],[krb_cv_c_bigendian=yes],
|
|
|
|
[AC_MSG_ERROR([specify either --enable-bigendian or --enable-littleendian])])
|
2000-01-09 20:58:00 +00:00
|
|
|
fi
|
2001-02-13 16:46:19 +00:00
|
|
|
])
|
|
|
|
if test "$krb_cv_c_bigendian" = "yes"; then
|
|
|
|
AC_DEFINE(WORDS_BIGENDIAN, 1, [define if target is big endian])dnl
|
2000-01-09 20:58:00 +00:00
|
|
|
fi
|
|
|
|
if test "$krb_cv_c_bigendian_compile" = "yes"; then
|
|
|
|
AC_DEFINE(ENDIANESS_IN_SYS_PARAM_H, 1, [define if sys/param.h defines the endiness])dnl
|
|
|
|
fi
|
2002-08-30 21:23:27 +00:00
|
|
|
AH_BOTTOM([
|
|
|
|
#if ENDIANESS_IN_SYS_PARAM_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/param.h>
|
|
|
|
# if BYTE_ORDER == BIG_ENDIAN
|
|
|
|
# define WORDS_BIGENDIAN 1
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
])
|
2000-01-09 20:58:00 +00:00
|
|
|
])
|