| 1 | #!/bin/sh | 
|---|
| 2 |  | 
|---|
| 3 | QMKSPEC=$1 | 
|---|
| 4 | VERBOSE=$2 | 
|---|
| 5 | SRCDIR=$3 | 
|---|
| 6 | OUTDIR=$4 | 
|---|
| 7 |  | 
|---|
| 8 | # debuggery | 
|---|
| 9 | [ "$VERBOSE" = "yes" ] && echo "Determining floating point  word-order... ($*)" | 
|---|
| 10 |  | 
|---|
| 11 | # build and run a test program | 
|---|
| 12 | test -d "$OUTDIR/config.tests/unix/doubleformat" || mkdir -p "$OUTDIR/config.tests/unix/doubleformat" | 
|---|
| 13 | "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" "$SRCDIR/config.tests/unix/doubleformat/doubleformattest.pro" -o "$OUTDIR/config.tests/unix/doubleformat/Makefile" >/dev/null 2>&1 | 
|---|
| 14 | cd "$OUTDIR/config.tests/unix/doubleformat" | 
|---|
| 15 |  | 
|---|
| 16 | DOUBLEFORMAT="UNKNOWN" | 
|---|
| 17 | [ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1 | 
|---|
| 18 |  | 
|---|
| 19 | if [ -f ./doubleformattest ]; then | 
|---|
| 20 | : # nop | 
|---|
| 21 | else | 
|---|
| 22 | [ "$VERBOSE" = "yes" ] && echo "Unknown floating point format!" | 
|---|
| 23 | exit 2 | 
|---|
| 24 | fi | 
|---|
| 25 |  | 
|---|
| 26 | # LE: strings | grep 0123ABCD0123ABCD | 
|---|
| 27 | # BE: strings | grep DCBA3210DCBA3210 | 
|---|
| 28 | # | 
|---|
| 29 | # LE arm-swapped-dword-order: strings | grep ABCD0123ABCD0123 | 
|---|
| 30 | # BE arm-swapped-dword-order: strings | grep 3210DCBA3210DCBA (untested) | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | if strings ./doubleformattest | grep "0123ABCD0123ABCD" >/dev/null 2>&1; then | 
|---|
| 34 | [ "$VERBOSE" = "yes" ] && echo "     Normal little endian format" | 
|---|
| 35 | DOUBLEFORMAT="LITTLE" | 
|---|
| 36 | elif strings ./doubleformattest | grep "ABCD0123ABCD0123" >/dev/null 2>&1; then | 
|---|
| 37 | [ "$VERBOSE" = "yes" ] && echo "     Swapped little endian format" | 
|---|
| 38 | DOUBLEFORMAT="LITTLESWAPPED" | 
|---|
| 39 | elif strings ./doubleformattest | grep "DCBA3210DCBA3210" >/dev/null 2>&1; then | 
|---|
| 40 | [ "$VERBOSE" = "yes" ] && echo "     Normal big endian format" | 
|---|
| 41 | DOUBLEFORMAT="BIG" | 
|---|
| 42 | elif strings ./doubleformattest | grep "3210DCBA3210DCBA" >/dev/null 2>&1; then | 
|---|
| 43 | [ "$VERBOSE" = "yes" ] && echo "     Swapped big endian format" | 
|---|
| 44 | DOUBLEFORMAT="BIGSWAPPED" | 
|---|
| 45 | fi | 
|---|
| 46 |  | 
|---|
| 47 | # done | 
|---|
| 48 | if [ "$DOUBLEFORMAT" = "LITTLE" ]; then | 
|---|
| 49 | [ "$VERBOSE" = "yes" ] && echo "Using little endian." | 
|---|
| 50 | exit 10 | 
|---|
| 51 | elif [ "$DOUBLEFORMAT" = "BIG" ]; then | 
|---|
| 52 | [ "$VERBOSE" = "yes" ] && echo "Using big endian." | 
|---|
| 53 | exit 11 | 
|---|
| 54 | elif [ "$DOUBLEFORMAT" = "LITTLESWAPPED" ]; then | 
|---|
| 55 | [ "$VERBOSE" = "yes" ] && echo "Using swapped little endian." | 
|---|
| 56 | exit 12 | 
|---|
| 57 | elif [ "$DOUBLEFORMAT" = "BIGSWAPPED" ]; then | 
|---|
| 58 | [ "$VERBOSE" = "yes" ] && echo "Using swapped big endian." | 
|---|
| 59 | exit 13 | 
|---|
| 60 | else | 
|---|
| 61 | [ "$VERBOSE" = "yes" ] && echo "Unknown floating point format!" | 
|---|
| 62 | exit 99 | 
|---|
| 63 | fi | 
|---|