Clean up default arch setting on Mac OS X
authorBradley T. Hughes <bradley.hughes@nokia.com>
Wed, 15 Feb 2012 12:49:55 +0000 (13:49 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 17 Feb 2012 10:44:29 +0000 (11:44 +0100)
Remove config.tests/mac/defaultarch.test, but do the same type of
default arch detection, only using the qmake binary instead of compiling
an empty file. Qt 5 will only support 10.6 and up, which means we
only support i386 and x86_64 now.

Change-Id: I24949ac803b965c523b1ee45cf769e266dcde134
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
config.tests/mac/defaultarch.test [deleted file]
configure

diff --git a/config.tests/mac/defaultarch.test b/config.tests/mac/defaultarch.test
deleted file mode 100755 (executable)
index 80f244a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-COMPILER=$1
-VERBOSE=$2
-WORKDIR=$3
-QT_MAC_DEFAULT_ARCH=
-
-touch defaultarch.c
-
-# compile something and run 'file' on it.
-if "$COMPILER" -c defaultarch.c 2>/dev/null 1>&2; then
-    FIlE_OUTPUT=`file defaultarch.o`
-    [ "$VERBOSE" = "yes" ] && echo "'file' reports compiler ($COMPILER) default architechture as: $FIlE_OUTPUT"
-
-fi
-rm -f defaultarch.c defaultarch.o
-
-# detect our known archs.
-if echo "$FIlE_OUTPUT" | grep '\<i386\>' > /dev/null 2>&1; then
-    QT_MAC_DEFAULT_ARCH=x86 # configure knows it as "x86" not "i386"
-fi
-if echo "$FIlE_OUTPUT" | grep '\<x86_64\>' > /dev/null 2>&1; then
-    QT_MAC_DEFAULT_ARCH=x86_64
-fi
-if echo "$FIlE_OUTPUT" | grep '\<ppc\>' > /dev/null 2>&1; then
-    QT_MAC_DEFAULT_ARCH=ppc
-fi
-if echo "$FIlE_OUTPUT" | grep '\<ppc64\>' > /dev/null 2>&1; then
-    QT_MAC_DEFAULT_ARCH=ppc64
-fi
-
-[ "$VERBOSE" = "yes" ] && echo "setting QT_MAC_DEFAULT_ARCH to \"$QT_MAC_DEFAULT_ARCH\""
-export QT_MAC_DEFAULT_ARCH
index 7e6aa9e..1215f2f 100755 (executable)
--- a/configure
+++ b/configure
@@ -6315,11 +6315,30 @@ if [ "$CFG_MAC_DWARF2" = "yes" ]; then
     QT_CONFIG="$QT_CONFIG dwarf2"
 fi
 
-# Set the default arch if there are no "-arch" arguments on the configure line
-if [ "$PLATFORM_MAC" = "yes" ]  && [ "$CFG_MAC_ARCHS" = "" ]; then
-    source "$mactests/defaultarch.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests"
-    CFG_MAC_ARCHS=" $QT_MAC_DEFAULT_ARCH"
-    [ "$OPT_VERBOSE" = "yes" ] && echo "Setting Mac architechture to$CFG_MAC_ARCHS."
+# Set the default Mac OS X arch if there are no "-arch" arguments on the configure line
+if [ "$BUILD_ON_MAC" = "yes" ]; then
+    DEFAULT_ARCH="$CFG_MAC_ARCHS"
+    if [ -z "$DEFAULT_ARCH" ]; then
+        case `file "${outpath}/bin/qmake"` in
+        *i?86)
+            DEFAULT_ARCH=x86
+            ;;
+        *x86_64)
+            DEFAULT_ARCH=x86_64
+            ;;
+        *ppc|*ppc64|*)
+            # unsupported/unknown
+            ;;
+        esac
+    fi
+    if [ -n "$DEFAULT_ARCH" ]; then
+        [ "$OPT_VERBOSE" = "yes" ] && echo "Setting default Mac OS X architechture to $DEFAULT_ARCH."
+        QT_CONFIG="$QT_CONFIG $DEFAULT_ARCH"
+        QMAKE_CONFIG="$QMAKE_CONFIG $DEFAULT_ARCH"
+        # Make the application arch follow the Qt arch for single arch builds.
+        # (for multiple-arch builds, set CONFIG manually in the application .pro file)
+        [ `echo "$DEFAULT_ARCH" | wc -w` -eq 1 ] && QTCONFIG_CONFIG="$QTCONFIG_CONFIG $DEFAULT_ARCH"
+    fi
 fi
 
 # ### Vestige
@@ -6463,7 +6482,6 @@ fi
 [ "$CFG_AVX" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG avx"
 [ "$CFG_IWMMXT" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG iwmmxt"
 [ "$CFG_NEON" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG neon"
-[ "$PLATFORM_MAC" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG $CFG_MAC_ARCHS"
 if [ "$CFG_CLOCK_GETTIME" = "yes" ]; then
     QT_CONFIG="$QT_CONFIG clock-gettime"
 fi
@@ -7279,19 +7297,10 @@ else
     QT_CONFIG="$QT_CONFIG qt_framework"
     QTCONFIG_CONFIG="$QTCONFIG_CONFIG qt_framework"
 fi
-if [ "$BUILD_ON_MAC" = "yes" ]; then
-    QT_CONFIG="$QT_CONFIG $CFG_MAC_ARCHS"
-fi
 if [ "$CFG_DEV" = "yes" ]; then
     QT_CONFIG="$QT_CONFIG private_tests"
 fi
 
-# Make the application arch follow the Qt arch for single arch builds.
-# (for multiple-arch builds, set CONFIG manually in the application .pro file)
-if [ `echo "$CFG_MAC_ARCHS" | wc -w` -eq 1 ]; then
-    QTCONFIG_CONFIG="$QTCONFIG_CONFIG $CFG_MAC_ARCHS"
-fi
-
 cat >>"$QTCONFIG.tmp" <<EOF
 #configuration
 CONFIG += $QTCONFIG_CONFIG