From 31142378774c3aa6f4c137441e23c89b15355a31 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 29 Jun 2016 11:39:27 +0200 Subject: Call arch test through the new qmake based configure system Detect host and target architecture from within qmake, and set QT_ARCH accordingly. Change-Id: I30255f88c7645d197bd07355a1dff02b377cbbe8 Reviewed-by: Oswald Buddenhagen --- config.tests/unix/arch.test | 77 ------------------------------ configure | 81 ++------------------------------ configure.json | 37 +++++++++++---- configure.pri | 98 ++++++++++++++++++++++++++++++--------- mkspecs/features/qt_configure.prf | 23 +++++---- 5 files changed, 120 insertions(+), 196 deletions(-) delete mode 100755 config.tests/unix/arch.test diff --git a/config.tests/unix/arch.test b/config.tests/unix/arch.test deleted file mode 100755 index cfb47def4f..0000000000 --- a/config.tests/unix/arch.test +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -QMKSPEC=$1 -VERBOSE=$2 -SRCDIR=$3 -OUTDIR=$4 -RESULTFILE=$5 -TARGET=$6 -QMAKE=$7 -QTCONF=$8 -shift 8 - -if [ "$TARGET" = "host" ]; then - VARPREFIX="CFG_HOST" - PROSUFFIX="_host" -else - VARPREFIX="CFG" - PROSUFFIX="" -fi - -LFLAGS="$SYSROOT_FLAG" -CXXFLAGS="$SYSROOT_FLAG" - -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 - -# 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" -[ -f Makefile ] && $MAKE distclean >/dev/null 2>&1 -OUTDIR=$OUTDIR "$QMAKE" -qtconf "$QTCONF" -nocache -spec "$QMKSPEC" "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 - - -ARCH="" -[ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1 - -if [ -f ./arch.exe ]; then - binary=./arch.exe -elif [ -f ./arch ]; then - binary=./arch -elif [ -f ./libarch.so ]; then - binary=./libarch.so -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 diff --git a/configure b/configure index e028ea69da..70b1b44130 100755 --- a/configure +++ b/configure @@ -486,13 +486,6 @@ CFG_NOBUILD_PARTS="" CFG_SKIP_MODULES="" CFG_ANDROID_STYLE_ASSETS=yes -# Target architecture -CFG_ARCH= -CFG_CPUFEATURES= -# Host architecture, same as CFG_ARCH when not cross-compiling -CFG_HOST_ARCH= -CFG_HOST_CPUFEATURES= - XPLATFORM= # This seems to be the QMAKESPEC, like "linux-g++" XPLATFORM_MAC=no # Whether target platform is OS X, iOS or tvOS XPLATFORM_IOS=no # Whether target platform is iOS @@ -526,7 +519,6 @@ QT_INSTALL_SETTINGS= QT_INSTALL_EXAMPLES= QT_INSTALL_TESTS= CFG_SYSROOT= -CFG_GCC_SYSROOT="yes" QT_HOST_PREFIX= QT_HOST_BINS= QT_HOST_LIBS= @@ -722,9 +714,6 @@ while [ "$#" -gt 0 ]; do sysroot) CFG_SYSROOT="$VAL" ;; - gcc-sysroot) - CFG_GCC_SYSROOT="$VAL" - ;; external-hostbindir) CFG_HOST_QT_TOOLS_PATH="$VAL" HostVar set HOST_QT_TOOLS "$VAL" @@ -1396,13 +1385,6 @@ if [ "$XPLATFORM_ANDROID" != "yes" ]; then fi fi -if [ -n "$CFG_SYSROOT" ] && [ "$CFG_GCC_SYSROOT" = "yes" ]; then - SYSROOT_FLAG="--sysroot=$CFG_SYSROOT" -else - SYSROOT_FLAG= -fi -export SYSROOT_FLAG # used by config.tests/unix/{compile.test,arch.test} - #setup the build parts if [ -z "$CFG_BUILD_PARTS" ]; then CFG_BUILD_PARTS="$QT_DEFAULT_BUILD_PARTS" @@ -1976,47 +1958,6 @@ if [ $? != "0" ]; then exit 101 fi -#------------------------------------------------------------------------------- -# determine the target and host architectures -#------------------------------------------------------------------------------- - -# Use config.tests/arch/arch.pro to have the compiler tell us what the target architecture is -OUTFILE=$outpath/arch.result -"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "target" $CFG_QMAKE_PATH $QTCONFFILE $I_FLAGS $D_FLAGS $L_FLAGS -if [ $? -eq 0 ]; then - eval `cat "$OUTFILE"` -else - echo - echo "Could not determine the target architecture!" - echo "Turn on verbose messaging (-v) to see the final report." -fi -rm -f "$OUTFILE" 2>/dev/null -[ -z "$CFG_ARCH" ] && CFG_ARCH="unknown" - -if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then - # Do the same test again, using the host compiler - SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "host" $CFG_QMAKE_PATH $QTCONFFILE $I_FLAGS $D_FLAGS $L_FLAGS - if [ $? -eq 0 ]; then - eval `cat "$OUTFILE"` - else - echo - echo "Could not determine the host architecture!" - echo "Turn on verbose messaging (-v) to see the final report." - fi - rm -f "$OUTFILE" 2>/dev/null - [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown" -else - # not cross compiling, host == target - CFG_HOST_ARCH="$CFG_ARCH" - CFG_HOST_CPUFEATURES="$CFG_CPUFEATURES" -fi -unset OUTFILE - -if [ "$OPT_VERBOSE" = "yes" ]; then - echo "System architecture: '$CFG_ARCH'" - echo "Host architecture: '$CFG_HOST_ARCH'" -fi - #------------------------------------------------------------------------------- # run configure tests #------------------------------------------------------------------------------- @@ -2024,24 +1965,8 @@ fi # copy some variables that are still being computed in the shell script into an input file for configure # This should go away in the future -QMAKE_TESTED_FEATURES="cpufeatures host_cpufeatures" -echo "# Feature defaults set by configure command line" > $outpath/config.tests/configure.cfg -for feature in $QMAKE_TESTED_FEATURES; do - if [ -n "$BASH_VERSION" ] && [ "${BASH_VERSION%%.*}" -gt 3 ]; then - upper=${feature^^*} - elif [ -n "$ZSH_VERSION" ]; then - upper=${(U)feature} - else - upper=`echo $feature | tr a-z A-Z` - fi - upper=`echo $upper | sed 's,-,_,g'` - eval "res=\$CFG_$upper" - if [ "$res" != "auto" ]; then - echo "config.input.$feature=$res" >> $relpath/config.tests/configure.cfg - fi -done - -cat >> "$outpath/config.tests/configure.cfg" < "$outpath/config.tests/configure.cfg" <