diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:18:55 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:18:55 (GMT) |
commit | e5fcad302d86d316390c6b0f62759a067313e8a9 (patch) | |
tree | c2afbf6f1066b6ce261f14341cf6d310e5595bc1 /config.tests/unix/endian.test | |
download | Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2 |
Long live Qt 4.5!
Diffstat (limited to 'config.tests/unix/endian.test')
-rwxr-xr-x | config.tests/unix/endian.test | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/config.tests/unix/endian.test b/config.tests/unix/endian.test new file mode 100755 index 0000000..2c21652 --- /dev/null +++ b/config.tests/unix/endian.test @@ -0,0 +1,55 @@ +#!/bin/sh + +QMKSPEC=$1 +VERBOSE=$2 +SRCDIR=$3 +OUTDIR=$4 + +# debuggery +[ "$VERBOSE" = "yes" ] && echo "Determining machine byte-order... ($*)" + +# build and run a test program +test -d "$OUTDIR/config.tests/unix/endian" || mkdir -p "$OUTDIR/config.tests/unix/endian" +"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "$SRCDIR/config.tests/unix/endian/endiantest.pro" -o "$OUTDIR/config.tests/unix/endian/Makefile" >/dev/null 2>&1 +cd "$OUTDIR/config.tests/unix/endian" + + +ENDIAN="UNKNOWN" +[ "$VERBOSE" = "yes" ] && make || make >/dev/null 2>&1 + +if [ -f ./endiantest.exe ]; then + binary=./endiantest.exe +else + binary=./endiantest +fi + + +if [ -f $binary ]; then + : # nop +else + [ "$VERBOSE" = "yes" ] && echo "Unknown byte order!" + exit 2 +fi + +if strings $binary | grep LeastSignificantByteFirst >/dev/null 2>&1; then + [ "$VERBOSE" = "yes" ] && echo " Found 'LeastSignificantByteFirst' in binary" + ENDIAN="LITTLE" +elif strings $binary | grep MostSignificantByteFirst >/dev/null 2>&1; then + [ "$VERBOSE" = "yes" ] && echo " Found 'MostSignificantByteFirst' in binary" + ENDIAN="BIG" +fi + +# make clean as this tests is compiled for both the host and the target +make distclean + +# done +if [ "$ENDIAN" = "LITTLE" ]; then + [ "$VERBOSE" = "yes" ] && echo "Using little endian." + exit 0 +elif [ "$ENDIAN" = "BIG" ]; then + [ "$VERBOSE" = "yes" ] && echo "Using big endian." + exit 1 +else + [ "$VERBOSE" = "yes" ] && echo "Unknown byte order!" + exit 2 +fi |