[Box Backup] Building Box Backup as Universal Binaries [OS X]

patrick machielse boxbackup@fluffy.co.uk
Fri, 6 Oct 2006 14:56:07 +0200


On 5-okt-2006, at 13:00, boxbackup-request@fluffy.co.uk wrote:

> A standard autoconf check determines endianness. It attempts to
> determine it from the header files if possible, else does a runtime
> check. The CXXFLAGS will most likely be passed to gcc when the  
> configure
> check is run and if it then builds it as per i386 you'll get back the
> wrong result (assuming it is using compile time detection with the
> headers). You should see the effects in config.log.
>
> Either way the result cannot be right for both so something will  
> break.

I'm building on ppc, for ppc/i386.

After some more digging, it seems the problem lies in the runtime ./ 
configure test for endianess:

int
main ()
{
#if BYTE_ORDER != BIG_ENDIAN
  not big endian
#endif

   ;
   return 0;
}

When building for both ppc and i386 architectures this generates a  
compiler error for i386, and concludes I'm on little endian machine,  
when I'm not.

On a ppc machine, I believe I can do the following:
a) configure/make for ppc only
b) configure/make for ppc/i386. this will assume little endian for  
both archs
c) combine the ppc part from a) with the i386 part of b) to get a  
working Universal Binary

On an intel machine I should be able to do:
a) configure/make for ppc only
b) configure/make for i386 only
c) combine the output of a) and b)

because ppc binaries run on an intel Mac just like they would on a  
ppc Mac. (and as a result any ./configure test that rely on the  
return value of a test program, and not on the return value of gcc,  
will run and produce the correct values.)

However, a better approach may be to modify lib/common/BoxConfig.h

/* Define to 1 if your processor stores words with the most  
significant byte
    first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */

to read:

/* Define to 1 if your processor stores words with the most  
significant byte
    first (like Motorola and SPARC, unlike Intel and VAX). */
#if __LITTLE_ENDIAN__
     #undef WORDS_BIGENDIAN
#endif

Building a universal binary should then hopefully succeed in 1 go..?

patrick