]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/expat/conftools/ac_c_bigendian_cross.m4
Turkish translations update from Çağrı Doğan.
[wxWidgets.git] / src / expat / conftools / ac_c_bigendian_cross.m4
... / ...
CommitLineData
1dnl @synopsis AC_C_BIGENDIAN_CROSS
2dnl
3dnl Check endianess even when crosscompiling
4dnl (partially based on the original AC_C_BIGENDIAN).
5dnl
6dnl The implementation will create a binary, and instead of running
7dnl the binary it will be grep'ed for some symbols that will look
8dnl different for different endianess of the binary.
9dnl
10dnl @author Guido Draheim <guidod@gmx.de>
11dnl
12AC_DEFUN([AC_C_BIGENDIAN_CROSS],
13[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
14[ac_cv_c_bigendian=unknown
15# See if sys/param.h defines the BYTE_ORDER macro.
16AC_TRY_COMPILE([#include <sys/types.h>
17#include <sys/param.h>], [
18#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
19 bogus endian macros
20#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
21AC_TRY_COMPILE([#include <sys/types.h>
22#include <sys/param.h>], [
23#if BYTE_ORDER != BIG_ENDIAN
24 not big endian
25#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
26if test $ac_cv_c_bigendian = unknown; then
27AC_TRY_RUN([main () {
28 /* Are we little or big endian? From Harbison&Steele. */
29 union
30 {
31 long l;
32 char c[sizeof (long)];
33 } u;
34 u.l = 1;
35 exit (u.c[sizeof (long) - 1] == 1);
36}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes,
37[ echo $ac_n "cross-compiling... " 2>&AC_FD_MSG ])
38fi])
39if test $ac_cv_c_bigendian = unknown; then
40AC_MSG_CHECKING(to probe for byte ordering)
41[
42cat >conftest.c <<EOF
43short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
44short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
45void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; }
46short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
47short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
48void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; }
49int main() { _ascii (); _ebcdic (); return 0; }
50EOF
51] if test -f conftest.c ; then
52 if ${CC-cc} -c conftest.c -o conftest.o && test -f conftest.o ; then
53 if test `grep -l BIGenDianSyS conftest.o` ; then
54 echo $ac_n ' big endian probe OK, ' 1>&AC_FD_MSG
55 ac_cv_c_bigendian=yes
56 fi
57 if test `grep -l LiTTleEnDian conftest.o` ; then
58 echo $ac_n ' little endian probe OK, ' 1>&AC_FD_MSG
59 if test $ac_cv_c_bigendian = yes ; then
60 ac_cv_c_bigendian=unknown;
61 else
62 ac_cv_c_bigendian=no
63 fi
64 fi
65 echo $ac_n 'guessing bigendian ... ' >&AC_FD_MSG
66 fi
67 fi
68AC_MSG_RESULT($ac_cv_c_bigendian)
69fi
70if test $ac_cv_c_bigendian = yes; then
71 AC_DEFINE(WORDS_BIGENDIAN, 1, [whether byteorder is bigendian])
72 BYTEORDER=4321
73else
74 BYTEORDER=1234
75fi
76AC_DEFINE_UNQUOTED(BYTEORDER, $BYTEORDER, [1234 = LIL_ENDIAN, 4321 = BIGENDIAN])
77if test $ac_cv_c_bigendian = unknown; then
78 AC_MSG_ERROR(unknown endianess - sorry, please pre-set ac_cv_c_bigendian)
79fi
80])