configure: detect endian via compile test
This avoids needing to execute a program and keeping an (incomplete) list when cross-compiling. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Tested-by: James Hogan <james.hogan@imgtec.com> [mips] Message-id: 1372649418-4987-1-git-send-email-vapier@gentoo.org Signed-off-by: Anthony Liguori <aliguori@amazon.com>
This commit is contained in:
parent
8aa15b6e52
commit
61cc919f73
40
configure
vendored
40
configure
vendored
@ -1433,39 +1433,27 @@ feature_not_found() {
|
|||||||
"configure was not able to find it"
|
"configure was not able to find it"
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -z "$cross_prefix" ; then
|
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
# big/little endian test
|
# big/little endian test
|
||||||
cat > $TMPC << EOF
|
cat > $TMPC << EOF
|
||||||
#include <inttypes.h>
|
short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
|
||||||
int main(void) {
|
short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
|
||||||
volatile uint32_t i=0x01234567;
|
extern int foo(short *, short *);
|
||||||
return (*((uint8_t*)(&i))) == 0x67;
|
int main(int argc, char *argv[]) {
|
||||||
|
return foo(big_endian, little_endian);
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if compile_prog "" "" ; then
|
if compile_object ; then
|
||||||
$TMPE && bigendian="yes"
|
if grep -q BiGeNdIaN $TMPO ; then
|
||||||
else
|
bigendian="yes"
|
||||||
echo big/little test failed
|
elif grep -q LiTtLeEnDiAn $TMPO ; then
|
||||||
fi
|
bigendian="no"
|
||||||
|
else
|
||||||
else
|
echo big/little test failed
|
||||||
|
|
||||||
# if cross compiling, cannot launch a program, so make a static guess
|
|
||||||
case "$cpu" in
|
|
||||||
arm)
|
|
||||||
# ARM can be either way; ask the compiler which one we are
|
|
||||||
if check_define __ARMEB__; then
|
|
||||||
bigendian=yes
|
|
||||||
fi
|
fi
|
||||||
;;
|
else
|
||||||
hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
|
echo big/little test failed
|
||||||
bigendian=yes
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
Loading…
Reference in New Issue
Block a user