config.tests/unix/endian.test
changeset 0 1918ee327afb
child 33 3e2da88830cd
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 #!/bin/sh
       
     2 
       
     3 QMKSPEC=$1
       
     4 VERBOSE=$2
       
     5 SRCDIR=$3
       
     6 OUTDIR=$4
       
     7 
       
     8 # debuggery
       
     9 [ "$VERBOSE" = "yes" ] && echo "Determining machine byte-order... ($*)"
       
    10 
       
    11 # build and run a test program
       
    12 test -d "$OUTDIR/config.tests/unix/endian" || mkdir -p "$OUTDIR/config.tests/unix/endian"
       
    13 "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "$SRCDIR/config.tests/unix/endian/endiantest.pro" -o "$OUTDIR/config.tests/unix/endian/Makefile" >/dev/null 2>&1
       
    14 cd "$OUTDIR/config.tests/unix/endian"
       
    15 
       
    16 
       
    17 ENDIAN="UNKNOWN"
       
    18 [ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1
       
    19 
       
    20 if [ -f ./endiantest.exe ]; then
       
    21     binary=./endiantest.exe
       
    22 else
       
    23     binary=./endiantest
       
    24 fi
       
    25 
       
    26 
       
    27 if [ -f $binary ]; then
       
    28     : # nop
       
    29 else
       
    30     [ "$VERBOSE" = "yes" ] && echo "Unknown byte order!"
       
    31     exit 2
       
    32 fi
       
    33 
       
    34 if strings $binary | grep LeastSignificantByteFirst >/dev/null 2>&1; then
       
    35     [ "$VERBOSE" = "yes" ] && echo "    Found 'LeastSignificantByteFirst' in binary"
       
    36     ENDIAN="LITTLE"
       
    37 elif strings $binary | grep MostSignificantByteFirst >/dev/null 2>&1; then
       
    38     [ "$VERBOSE" = "yes" ] && echo "    Found 'MostSignificantByteFirst' in binary"
       
    39     ENDIAN="BIG"
       
    40 fi
       
    41 
       
    42 # make clean as this tests is compiled for both the host and the target
       
    43 $MAKE distclean
       
    44 
       
    45 # done
       
    46 if [ "$ENDIAN" = "LITTLE" ]; then
       
    47     [ "$VERBOSE" = "yes" ] && echo "Using little endian."
       
    48     exit 0
       
    49 elif [ "$ENDIAN" = "BIG" ]; then
       
    50     [ "$VERBOSE" = "yes" ] && echo "Using big endian."
       
    51     exit 1
       
    52 else
       
    53     [ "$VERBOSE" = "yes" ] && echo "Unknown byte order!"
       
    54     exit 2
       
    55 fi