I have installed the following patch into Autoconf in an attempt to fix the problem. However, I have not tested this under Mac OS X, so it'd help if someone with access to that environment could test it.
2007-02-27 Paul Eggert <[EMAIL PROTECTED]> * NEWS: AC_C_BIGENDIAN now supports universal binaries a la Mac OS X. * doc/autoconf.texi (C Compiler): Document this. There is a new extra argument ACTION-IF-UNIVERSAL. * lib/autoconf/c.m4 (AC_C_BIGENDIAN): Implement this. Add support for Solaris-style _LITTLE_ENDIAN and _BIG_ENDIAN. Reindent for sanity's sake. Index: NEWS =================================================================== RCS file: /cvsroot/autoconf/autoconf/NEWS,v retrieving revision 1.424 diff -u -p -r1.424 NEWS --- NEWS 2 Feb 2007 14:11:43 -0000 1.424 +++ NEWS 28 Feb 2007 00:03:28 -0000 @@ -1,5 +1,7 @@ * Major changes in Autoconf 2.61b (????-??-??) +** AC_C_BIGENDIAN now supports universal binaries a la Mac OS X. + ** Autoconf now requires GNU M4 1.4.5 or later. Earlier versions of M4 have a bug in macro tracing that interferes with the interaction between Autoconf and Automake. GNU M4 1.4.8 or later is recommended. Index: doc/autoconf.texi =================================================================== RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v retrieving revision 1.1132 diff -u -p -r1.1132 autoconf.texi --- doc/autoconf.texi 8 Feb 2007 23:42:46 -0000 1.1132 +++ doc/autoconf.texi 28 Feb 2007 00:03:29 -0000 @@ -6457,7 +6457,7 @@ This macro is obsolescent, as current C New programs need not use this macro. @end defmac [EMAIL PROTECTED] AC_C_BIGENDIAN (@ovar{action-if-true}, @ovar{action-if-false}, @ovar{action-if-unknown}) [EMAIL PROTECTED] AC_C_BIGENDIAN (@ovar{action-if-true}, @ovar{action-if-false}, @ovar{action-if-unknown}, @ovar{action-if-universal}) @acindex{C_BIGENDIAN} @cvindex WORDS_BIGENDIAN @cindex Endianness @@ -6471,11 +6471,21 @@ system header files. When cross-compili grep'ed for some magic values. @var{action-if-unknown} is executed if the latter case fails to determine the byte sex of the host system. +In some cases a single run of a compiler can generate code for multiple +architectures. This can happen, for example, when generating Mac OS X +universal binary files, which work on both PowerPC and Intel +architectures. In this case, the different variants might be for +different architectures whose endiannesses differ. If [EMAIL PROTECTED] detects this, it executes @var{action-if-universal} +instead of @var{action-if-unknown}. + The default for @var{action-if-true} is to define @samp{WORDS_BIGENDIAN}. The default for @var{action-if-false} is to do -nothing. And finally, the default for @var{action-if-unknown} is to -abort configure and tell the installer which variable he should preset -to bypass this test. +nothing. The default for @var{action-if-unknown} is to +abort configure and tell the installer how to bypass this test. +And finally, the default for @var{action-if-universal} is to define [EMAIL PROTECTED] or not, depending on the architecture that the +code is being generated for. @end defmac @defmac AC_C_CONST Index: lib/autoconf/c.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v retrieving revision 1.242 diff -u -p -r1.242 c.m4 --- lib/autoconf/c.m4 7 Dec 2006 06:39:40 -0000 1.242 +++ lib/autoconf/c.m4 28 Feb 2007 00:03:29 -0000 @@ -1367,74 +1367,137 @@ fi ])# AC_C_CHAR_UNSIGNED -# AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN]) +# AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN], +# [ACTION-IF-UNIVERSAL]) # ------------------------------------------------------------------------- AC_DEFUN([AC_C_BIGENDIAN], -[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian, -[# See if sys/param.h defines the BYTE_ORDER macro. -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h> -#include <sys/param.h> -], -[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ - && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) - bogus endian macros -#endif -])], -[# It does; now see whether it defined to BIG_ENDIAN or not. -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h> -#include <sys/param.h> -], [#if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif -])], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=no])], -[# It does not; compile a test program. -AC_RUN_IFELSE( -[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[ - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long int l; - char c[sizeof (long int)]; - } u; - u.l = 1; - return u.c[sizeof (long int) - 1] == 1; -]])], - [ac_cv_c_bigendian=no], - [ac_cv_c_bigendian=yes], -[# try to guess the endianness by grepping values into an object file - ac_cv_c_bigendian=unknown - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( -[[short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; -void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; -void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]], -[[ _ascii (); _ebcdic (); ]])], -[if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then - ac_cv_c_bigendian=yes -fi -if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; 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])])])]) -case $ac_cv_c_bigendian in - yes) - m4_default([$1], - [AC_DEFINE([WORDS_BIGENDIAN], 1, - [Define to 1 if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;; - no) - $2 ;; - *) - m4_default([$3], - [AC_MSG_ERROR([unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help])]) ;; -esac +[AH_VERBATIM([WORDS_BIGENDIAN], +[/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ +#if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +#elif ! defined __LITTLE_ENDIAN__ +/* #undef WORDS_BIGENDIAN */ +#endif])dnl + AC_CACHE_CHECK([whether byte ordering is bigendian], [ac_cv_c_bigendian], + [ac_cv_c_bigendian=unknown + # See if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if ! (defined __BIG_ENDIAN__ || defined __LITLE_ENDIAN__) + neither is defined; + #endif + ]])], + [ac_cv_c_bigendian=universal]) + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/types.h> + #include <sys/param.h> + ]], + [[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + ]])], + [# It does; now see whether it defined to BIG_ENDIAN or not. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/types.h> + #include <sys/param.h> + ]], + [[#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + ]])], + [ac_cv_c_bigendian=yes], + [ac_cv_c_bigendian=no])]) + fi + if test $ac_cv_c_bigendian = unknown; then + # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <limits.h> + ]], + [[#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + ]])], + [# It does; now see whether it defined to _BIG_ENDIAN or not. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <limits.h> + ]], + [[#ifndef _BIG_ENDIAN + not big endian + #endif + ]])], + [ac_cv_c_bigendian=yes], + [ac_cv_c_bigendian=no])]) + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + AC_RUN_IFELSE( + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], + [[ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + ]])], + [ac_cv_c_bigendian=no], + [ac_cv_c_bigendian=yes], + [# Try to guess by grepping values from an object file. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + ]], + [[return use_ascii (foo) == use_ebcdic (foo);]])], + [if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; 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])]) + fi]) + case $ac_cv_c_bigendian in #( + yes) + m4_default([$1], + [AC_DEFINE([WORDS_BIGENDIAN], 1)]);; #( + no) + $2 ;; #( + universal) + $4 ;; #( + *) + m4_default([$3], + [AC_MSG_ERROR([unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help])]) ;; + esac ])# AC_C_BIGENDIAN