endian.m4 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. dnl Copyright (C) 1993-2003 Free Software Foundation, Inc.
  2. dnl This file is free software, distributed under the terms of the GNU
  3. dnl General Public License. As a special exception to the GNU General
  4. dnl Public License, this file may be distributed as part of a program
  5. dnl that contains a configuration script generated by Autoconf, under
  6. dnl the same distribution terms as the rest of that program.
  7. dnl From Bruno Haible, Marcus Daniels.
  8. AC_PREREQ(2.13)
  9. AC_DEFUN([CL_WORDS_LITTLEENDIAN],
  10. [AC_CACHE_CHECK(byte ordering, cl_cv_sys_endian, [
  11. AC_TRY_RUN([int main () {
  12. /* Are we little or big endian? From Harbison&Steele. */
  13. union
  14. {
  15. long l;
  16. char c[sizeof (long)];
  17. } u;
  18. u.l = 1;
  19. exit (u.c[0] == 1);
  20. }],
  21. cl_cv_sys_endian="big endian",
  22. cl_cv_sys_endian="little endian",
  23. : # must guess the endianness
  24. )
  25. if test -z "$cl_cv_sys_endian"; then
  26. AC_EGREP_CPP(yes,[#if defined(m68k) || defined(__m68k__) || defined(mc68000) || defined(mc68020) || defined(__mc68020__) || defined(sparc) || defined(__sparc__) || defined(MIPSEB) || defined(__MIPSEB__) || defined(hppa) || defined(__hppa) || defined(m88000) || defined(__m88k__)
  27. yes
  28. #endif
  29. ], cl_cv_sys_endian="big endian")
  30. fi
  31. if test -z "$cl_cv_sys_endian"; then
  32. AC_EGREP_CPP(yes,[#if defined(i386) || defined(__i386) || defined(__i386__) || defined(_I386) || defined(MIPSEL) || defined(__MIPSEL__) || defined(__alpha)
  33. yes
  34. #endif
  35. ], cl_cv_sys_endian="little endian")
  36. fi
  37. if test -z "$cl_cv_sys_endian"; then
  38. cl_cv_sys_endian="guessing little endian"
  39. fi
  40. ])
  41. case "$cl_cv_sys_endian" in
  42. *little*)
  43. AC_DEFINE(WORDS_LITTLEENDIAN, 1,
  44. [Define if the machine's byte ordering is little endian.]) ;;
  45. *big*) ;;
  46. esac
  47. ])