source: heimdal/trunk/cf/krb-bigendian.m4@ 3

Last change on this file since 3 was 1, checked in by Paul Smedley, 10 years ago

Initial commit of Heimdal 1.5.3

File size: 2.0 KB
Line 
1dnl
2dnl $Id$
3dnl
4
5dnl check if this computer is little or big-endian
6dnl if we can figure it out at compile-time then don't define the cpp symbol
7dnl otherwise test for it and define it. also allow options for overriding
8dnl it when cross-compiling
9
10AC_DEFUN([KRB_C_BIGENDIAN], [
11AC_ARG_ENABLE(bigendian,
12 AS_HELP_STRING([--enable-bigendian],[the target is big endian]),
13krb_cv_c_bigendian=yes)
14AC_ARG_ENABLE(littleendian,
15 AS_HELP_STRING([--enable-littleendian],[the target is little endian]),
16krb_cv_c_bigendian=no)
17AC_CACHE_CHECK([whether byte order is known at compile time],
18krb_cv_c_bigendian_compile,
19[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
20#include <sys/types.h>
21#include <sys/param.h>
22#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
23 bogus endian macros
24#endif]])],[krb_cv_c_bigendian_compile=yes],[krb_cv_c_bigendian_compile=no])])
25AC_CACHE_CHECK(whether byte ordering is bigendian, krb_cv_c_bigendian,[
26 if test "$krb_cv_c_bigendian_compile" = "yes"; then
27 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
28#include <sys/types.h>
29#include <sys/param.h>
30#if BYTE_ORDER != BIG_ENDIAN
31 not big endian
32#endif]])],[krb_cv_c_bigendian=yes],[krb_cv_c_bigendian=no])
33 else
34 AC_RUN_IFELSE([AC_LANG_SOURCE([[main (int argc, char **argv) {
35 /* Are we little or big endian? From Harbison&Steele. */
36 union
37 {
38 long l;
39 char c[sizeof (long)];
40 } u;
41 u.l = 1;
42 exit (u.c[sizeof (long) - 1] == 1);
43 }]])],[krb_cv_c_bigendian=no],[krb_cv_c_bigendian=yes],
44 [AC_MSG_ERROR([specify either --enable-bigendian or --enable-littleendian])])
45 fi
46])
47if test "$krb_cv_c_bigendian" = "yes"; then
48 AC_DEFINE(WORDS_BIGENDIAN, 1, [define if target is big endian])dnl
49fi
50if test "$krb_cv_c_bigendian_compile" = "yes"; then
51 AC_DEFINE(ENDIANESS_IN_SYS_PARAM_H, 1, [define if sys/param.h defines the endiness])dnl
52fi
53AH_BOTTOM([
54#ifdef ENDIANESS_IN_SYS_PARAM_H
55# include <sys/types.h>
56# include <sys/param.h>
57# if BYTE_ORDER == BIG_ENDIAN
58# define WORDS_BIGENDIAN 1
59# endif
60#endif
61])
62])
Note: See TracBrowser for help on using the repository browser.