Subject: Re: CVS commit: basesrc
To: Simon Burge <simonb@wasabisystems.com>
From: Todd Vierling <tv@wasabisystems.com>
List: source-changes
Date: 11/11/2000 00:25:15
On Sat, 11 Nov 2000, Simon Burge wrote:

: > > While I do agree with you on that point.. It does seem like there should be a
: > > way to determine the endianess of the machine you are attempting to build for.

: Unfortunately, Tim is trying to determine the endianness of the _target_
: platform and not the host platform (this is in a cross-compile environment).

For NetBSD (and most other 4.4BSD based) targets,

===== CUT - endian-test.i =====
#include <machine/endian.h>
#if BYTE_ORDER == BIG_ENDIAN
#error big endian
#endif
===== CUT - endian-test.i =====

then do:

    if ${CC} -E endian-test.i >/dev/null 2>&1; then
        [...little-endian...]
    else
        [...big-endian...]
    fi

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  http://www.wasabisystems.com/
-- Speed, stability, security, and support.  Wasabi NetBSD:  Run with it.