2012-03-27 17:43:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
QMKSPEC=$1
|
|
|
|
VERBOSE=$2
|
|
|
|
SRCDIR=$3
|
|
|
|
OUTDIR=$4
|
|
|
|
RESULTFILE=$5
|
2013-02-15 10:57:08 +00:00
|
|
|
TARGET=$6
|
2012-07-20 13:26:07 +00:00
|
|
|
shift 6
|
|
|
|
|
2013-02-15 10:57:08 +00:00
|
|
|
if [ "$TARGET" = "host" ]; then
|
|
|
|
VARPREFIX="CFG_HOST"
|
|
|
|
PROSUFFIX="_host"
|
|
|
|
else
|
|
|
|
VARPREFIX="CFG"
|
|
|
|
PROSUFFIX=""
|
|
|
|
fi
|
|
|
|
|
2012-07-20 13:26:07 +00:00
|
|
|
LFLAGS="$SYSROOT_FLAG"
|
|
|
|
CXXFLAGS="$SYSROOT_FLAG"
|
|
|
|
|
2014-01-07 07:17:57 +00:00
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
PARAM=$1
|
|
|
|
case $PARAM in
|
|
|
|
-L*|-l*)
|
|
|
|
LFLAGS="$LFLAGS $PARAM"
|
|
|
|
;;
|
|
|
|
-I*)
|
|
|
|
INC=`echo $PARAM | sed -e 's/^-I//'`
|
|
|
|
INCLUDEPATH="$INCLUDEPATH $INC"
|
|
|
|
;;
|
|
|
|
-D*)
|
|
|
|
CXXFLAGS="$CXXFLAGS $PARAM"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2012-03-27 17:43:45 +00:00
|
|
|
# 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"
|
|
|
|
cd "$OUTDIR/config.tests/arch"
|
2012-09-13 21:46:41 +00:00
|
|
|
[ -f Makefile ] && $MAKE distclean >/dev/null 2>&1
|
2014-01-07 07:17:57 +00:00
|
|
|
OUTDIR=$OUTDIR "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" "LIBS+=$LFLAGS" "QMAKE_CXXFLAGS+=$CXXFLAGS" "INCLUDEPATH+=$INCLUDEPATH" "CONFIG-=app_bundle" "$SRCDIR/config.tests/arch/arch$PROSUFFIX.pro" >/dev/null 2>&1 || echo "qmake is broken" >&2
|
2012-03-27 17:43:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
ARCH=""
|
|
|
|
[ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1
|
|
|
|
|
|
|
|
if [ -f ./arch.exe ]; then
|
|
|
|
binary=./arch.exe
|
|
|
|
elif [ -f ./arch ]; then
|
|
|
|
binary=./arch
|
2013-03-04 09:16:42 +00:00
|
|
|
elif [ -f ./libarch.so ]; then
|
|
|
|
binary=./libarch.so
|
2012-03-27 17:43:45 +00:00
|
|
|
else
|
|
|
|
[ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2011-12-31 22:40:49 +00:00
|
|
|
if strings - $binary 2>/dev/null | \
|
2013-06-21 12:40:32 +00:00
|
|
|
awk -F: '/\=\=Qt\=magic\=Qt\=\= Architecture/ { print "'$VARPREFIX'_ARCH=\"" $2 "\"" }
|
|
|
|
/\=\=Qt\=magic\=Qt\=\= Sub-architecture/ { print "'$VARPREFIX'_CPUFEATURES=\"" $2 "\"" }' > "$RESULTFILE"
|
2011-12-31 22:40:49 +00:00
|
|
|
then
|
|
|
|
[ "$VERBOSE" = "yes" ] && echo " Found architecture in binary" && \
|
|
|
|
cat "$RESULTFILE"
|
|
|
|
else
|
2012-03-27 17:43:45 +00:00
|
|
|
[ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!"
|
|
|
|
exit 2
|
2011-12-31 22:40:49 +00:00
|
|
|
fi
|
2012-03-27 17:43:45 +00:00
|
|
|
|
|
|
|
$MAKE distclean >/dev/null 2>&1
|