qt5base-lts/config.tests/unix/arch.test
Thiago Macieira 735f7e6248 Record the sub-architecture (CPU features enabled in the compiler)
If the system's compiler has extra features on top of the base
settings enabled or if the mkspec or $CXXFLAGS variable included some,
record them.

This will allow us to choose whether or not to use our own special
compilers, based on whether the system default compiler contains it or
not.

Change-Id: I87cada9fab4cfa58846a831d0a7c7b50d8fa87fd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-05-30 17:28:07 +02:00

44 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
QMKSPEC=$1
VERBOSE=$2
SRCDIR=$3
OUTDIR=$4
RESULTFILE=$5
VARPREFIX=$6
# debuggery
[ "$VERBOSE" = "yes" ] && echo "Determining architecture... ($*)"
# build a test program but don't run it
test -d "$OUTDIR/config.tests/arch" || mkdir -p "$OUTDIR/config.tests/arch"
[ -f Makefile ] && $MAKE distclean >/dev/null 2>&1
"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" "LIBS+=$SYSROOT_FLAG" "QMAKE_CXXFLAGS+=$SYSROOT_FLAG" "$SRCDIR/config.tests/arch/arch.pro" -o "$OUTDIR/config.tests/arch/Makefile" >/dev/null 2>&1 || echo "qmake is broken" >&2
cd "$OUTDIR/config.tests/arch"
ARCH=""
[ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1
if [ -f ./arch.exe ]; then
binary=./arch.exe
elif [ -f ./arch ]; then
binary=./arch
else
[ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!"
exit 2
fi
if strings - $binary 2>/dev/null | \
awk -F: '/==Qt=magic=Qt== Architecture/ { print "'$VARPREFIX'_ARCH=\"" $2 "\"" }
/==Qt=magic=Qt== Sub-architecture/ { print "'$VARPREFIX'_CPUFEATURES=\"" $2 "\"" }' > "$RESULTFILE"
then
[ "$VERBOSE" = "yes" ] && echo " Found architecture in binary" && \
cat "$RESULTFILE"
else
[ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!"
exit 2
fi
$MAKE distclean >/dev/null 2>&1