Index: ChangeLog from Alexandre Duret-Lutz * aclang.m4 (AC_C_BIGENDIAN): Implement Guido Draheim's idea to guess endianess by grep'ing values into an object file when cross-compiling. Index: aclang.m4 =================================================================== RCS file: /home/adl/CVSROOT/ac/aclang.m4,v retrieving revision 1.2 diff -u -r1.2 aclang.m4 --- aclang.m4 2000/10/06 18:48:00 1.2 +++ aclang.m4 2000/10/07 17:44:47 @@ -1156,7 +1156,7 @@ not big endian #endif ])], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=no])], -[# It does not; compile and run a test. +[# It does not; compile a test program. AC_TRY_RUN( [int main () @@ -1169,13 +1169,45 @@ } u; u.l = 1; exit (u.c[sizeof (long) - 1] == 1); -}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes]) -])]) -if test $ac_cv_c_bigendian = yes; then - AC_DEFINE(WORDS_BIGENDIAN, 1, - [Define if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX).]) -fi +}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], +[# try to guess the endianess by grep'ing values into an object file + AC_LANG_CONFTEST( +[short ascii_mm[[]] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[[]] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; } +short ebcdic_ii[[]] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[[]] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; } +int main() { _ascii (); _ebcdic (); return 0; }]) + ac_cv_c_bigendian=unknown + if AC_TRY_EVAL([ac_compile]) && test -s conftest.$ac_objext; then + if test `grep -l BIGenDianSyS conftest.$ac_objext` ; then + ac_cv_c_bigendian=yes + fi + if test `grep -l LiTTleEnDian conftest.$ac_objext` ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi + else + echo "configure: failed program was:" >&AC_FD_LOG + cat conftest.$ac_ext >&AC_FD_LOG + fi + rm -f conftest.$ac_objext conftest.$ac_ext])])]) +case $ac_cv_c_bigendian in + yes) + AC_DEFINE(WORDS_BIGENDIAN, 1, + [Define if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX).]);; + no) + ;; + *) + AC_MSG_ERROR([unknown endianess +presetting ac_cv_c_bigendian=no (or yes) will help]);; +esac ])# AC_C_BIGENDIAN