--- configure.orig	2012-09-17 11:00:59.000000000 -0400
+++ configure	2012-09-17 11:01:07.000000000 -0400
@@ -920,6 +920,7 @@
 QT_INSTALL_DOCS=
 QT_INSTALL_HEADERS=
 QT_INSTALL_LIBS=
+QT_INSTALL_FRAMEWORKS=
 QT_INSTALL_BINS=
 QT_INSTALL_PLUGINS=
 QT_INSTALL_IMPORTS=
@@ -1380,6 +1381,9 @@
     libdir)
         QT_INSTALL_LIBS="$VAL"
         ;;
+    frameworkdir)
+        QT_INSTALL_FRAMEWORKS="$VAL"
+        ;;
     qtnamespace)
         QT_NAMESPACE="$VAL"
         ;;
@@ -3697,6 +3701,19 @@
     fi
     QT_INSTALL_LIBS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_LIBS"`
 
+    #frameworks
+    if [ -z "$QT_INSTALL_FRAMEWORKS" ]; then #default
+        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
+	    if [ "$PLATFORM_MAC" = "yes" ]; then
+	        if [ "$CFG_FRAMEWORK" = "yes" ]; then
+		    QT_INSTALL_FRAMEWORKS="/Libraries/Frameworks"
+                fi
+            fi
+        fi
+        [ -z "$QT_INSTALL_FRAMEWORKS" ] && QT_INSTALL_FRAMEWORKS="$QT_INSTALL_PREFIX/Library/Frameworks" #fallback
+    fi
+    QT_INSTALL_FRAMEWORKS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_FRAMEWORKS"`
+
     #bins
     if [ -z "$QT_INSTALL_BINS" ]; then #default
         if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
@@ -4752,6 +4769,7 @@
 DOCUMENTATION_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_docspath=$QT_INSTALL_DOCS"`
 HEADERS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_hdrspath=$QT_INSTALL_HEADERS"`
 LIBRARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_libspath=$QT_INSTALL_LIBS"`
+FRAMEWORKS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_frameworkspath=$QT_INSTALL_FRAMEWORKS"`
 BINARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_binspath=$QT_INSTALL_BINS"`
 PLUGINS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_plugpath=$QT_INSTALL_PLUGINS"`
 IMPORTS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_impspath=$QT_INSTALL_IMPORTS"`
@@ -4777,6 +4795,7 @@
     HOSTDOCUMENTATION_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_docspath=$QT_HOST_PREFIX/doc"`
     HOSTHEADERS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_hdrspath=$QT_HOST_PREFIX/include"`
     HOSTLIBRARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_libspath=$QT_HOST_PREFIX/lib"`
+    HOSTFRAMEWORKS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_frameworkspath=$QT_HOST_PREFIX/Library/Frameworks"`
     HOSTBINARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_binspath=$QT_HOST_PREFIX/bin"`
     HOSTPLUGINS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_plugpath=$QT_HOST_PREFIX/plugins"`
     HOSTIMPORTS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_impspath=$QT_HOST_PREFIX/IMPORTS"`
@@ -4794,6 +4813,7 @@
 static const char qt_configure_documentation_path_str[256 + 12] = "$HOSTDOCUMENTATION_PATH_STR";
 static const char qt_configure_headers_path_str      [256 + 12] = "$HOSTHEADERS_PATH_STR";
 static const char qt_configure_libraries_path_str    [256 + 12] = "$HOSTLIBRARIES_PATH_STR";
+static const char qt_configure_frameworks_path_str   [256 + 12] = "$HOSTFRAMEWORKS_PATH_STR";
 static const char qt_configure_binaries_path_str     [256 + 12] = "$HOSTBINARIES_PATH_STR";
 static const char qt_configure_plugins_path_str      [256 + 12] = "$HOSTPLUGINS_PATH_STR";
 static const char qt_configure_imports_path_str      [256 + 12] = "$HOSTIMPORTS_PATH_STR";
@@ -4812,6 +4832,7 @@
 static const char qt_configure_documentation_path_str[256 + 12] = "$DOCUMENTATION_PATH_STR";
 static const char qt_configure_headers_path_str      [256 + 12] = "$HEADERS_PATH_STR";
 static const char qt_configure_libraries_path_str    [256 + 12] = "$LIBRARIES_PATH_STR";
+static const char qt_configure_frameworks_path_str   [256 + 18] = "$FRAMEWORKS_PATH_STR";
 static const char qt_configure_binaries_path_str     [256 + 12] = "$BINARIES_PATH_STR";
 static const char qt_configure_plugins_path_str      [256 + 12] = "$PLUGINS_PATH_STR";
 static const char qt_configure_imports_path_str      [256 + 12] = "$IMPORTS_PATH_STR";
@@ -4837,6 +4858,7 @@
 #define QT_CONFIGURE_DOCUMENTATION_PATH qt_configure_documentation_path_str + 12;
 #define QT_CONFIGURE_HEADERS_PATH qt_configure_headers_path_str + 12;
 #define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;
+#define QT_CONFIGURE_FRAMEWORKS_PATH qt_configure_frameworks_path_str + 18;
 #define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;
 #define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;
 #define QT_CONFIGURE_IMPORTS_PATH qt_configure_imports_path_str + 12;
@@ -4996,20 +5018,11 @@
             EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(CARBON_CFLAGS)"
             EXTRA_OBJS="qsettings_mac.o qcore_mac.o"
             EXTRA_SRCS="\"$relpath/src/corelib/io/qsettings_mac.cpp\" \"$relpath/src/corelib/kernel/qcore_mac.cpp\""
-	    if echo "$CFG_MAC_ARCHS" | grep x86 > /dev/null 2>&1; then # matches both x86 and x86_64
-		X86_CFLAGS="-arch i386"
-		X86_LFLAGS="-arch i386"
-		EXTRA_CFLAGS="$X86_CFLAGS $EXTRA_CFLAGS"
-		EXTRA_CXXFLAGS="$X86_CFLAGS $EXTRA_CXXFLAGS"
-                EXTRA_LFLAGS="$EXTRA_LFLAGS $X86_LFLAGS"
-            fi
-	    if echo "$CFG_MAC_ARCHS" | grep ppc > /dev/null 2>&1; then # matches both ppc and ppc64
-		PPC_CFLAGS="-arch ppc"
-		PPC_LFLAGS="-arch ppc"
-		EXTRA_CFLAGS="$PPC_CFLAGS $EXTRA_CFLAGS"
-		EXTRA_CXXFLAGS="$PPC_CFLAGS $EXTRA_CXXFLAGS"
-                EXTRA_LFLAGS="$EXTRA_LFLAGS $PPC_LFLAGS"
-            fi
+           ARCH_CFLAGS="-arch @ARCHES@"
+           ARCH_LFLAGS="-arch @ARCHES@"
+           EXTRA_CFLAGS="$ARCH_CFLAGS $EXTRA_CFLAGS"
+           EXTRA_CXXFLAGS="$ARCH_CFLAGS $EXTRA_CXXFLAGS"
+           EXTRA_LFLAGS="$EXTRA_LFLAGS $ARCH_LFLAGS"
 	    if [ '!' -z "$CFG_SDK" ]; then
 		echo "SDK_LFLAGS =-Wl,-syslibroot,$CFG_SDK" >>"$mkfile"
 		echo "SDK_CFLAGS =-isysroot $CFG_SDK" >>"$mkfile"
@@ -5441,9 +5454,9 @@
         psql)
             if [ "$CFG_SQL_psql" != "no" ]; then
                 # Be careful not to use native pg_config when cross building.
-                if [ "$XPLATFORM_MINGW" != "yes" ] && "$WHICH" pg_config >/dev/null 2>&1; then
-                    QT_CFLAGS_PSQL=`pg_config --includedir 2>/dev/null`
-                    QT_LFLAGS_PSQL=`pg_config --libdir 2>/dev/null`
+                if [ "$XPLATFORM_MINGW" != "yes" ] && "$WHICH" @PATH_TO_PG_CONFIG@pg_config >/dev/null 2>&1; then
+                    QT_CFLAGS_PSQL=`@PATH_TO_PG_CONFIG@pg_config --includedir 2>/dev/null`
+                    QT_LFLAGS_PSQL=`@PATH_TO_PG_CONFIG@pg_config --libdir 2>/dev/null`
                 fi
                 [ -z "$QT_CFLAGS_PSQL" ] || QT_CFLAGS_PSQL="-I$QT_CFLAGS_PSQL"
                 [ -z "$QT_LFLAGS_PSQL" ] || QT_LFLAGS_PSQL="-L$QT_LFLAGS_PSQL"
@@ -7097,16 +7110,8 @@
 
 # set the global Mac deployment target. This is overridden on an arch-by-arch basis
 # in some cases, see code further down
-case "$PLATFORM,$CFG_MAC_COCOA" in
-    macx*,yes)
-	# Cocoa
-	QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.5
-	;;
-    macx*,no)
-	# gcc, Carbon
-	QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.4
-	;;
-esac
+
+QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET @MACOSX_DEPLOYMENT_TARGET@
 
 # disable Qt 3 support on VxWorks, Symbian and INTEGRITY
 case "$XPLATFORM" in
@@ -7844,28 +7849,28 @@
 # env. variable. 
 if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] ; then
     if echo "$CFG_MAC_ARCHS" | grep '\<x86\>' > /dev/null 2>&1; then
-        QMakeVar add QMAKE_CFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
-        QMakeVar add QMAKE_CXXFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
-        QMakeVar add QMAKE_LFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
-        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86 "-arch i386 -Xarch_i386 -mmacosx-version-min=10.4"
+        QMakeVar add QMAKE_CFLAGS "-Xarch_i386 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_CXXFLAGS "-Xarch_i386 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_LFLAGS "-Xarch_i386 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86 "-arch i386 -Xarch_i386 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
     fi
     if echo "$CFG_MAC_ARCHS" | grep '\<ppc\>' > /dev/null 2>&1; then
-        QMakeVar add QMAKE_CFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
-        QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
-        QMakeVar add QMAKE_LFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
-        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC "-arch ppc -Xarch_ppc -mmacosx-version-min=10.4"
+        QMakeVar add QMAKE_CFLAGS "-Xarch_ppc -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_LFLAGS "-Xarch_ppc -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC "-arch ppc -Xarch_ppc -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
     fi
     if echo "$CFG_MAC_ARCHS" | grep '\<x86_64\>' > /dev/null 2>&1; then
-        QMakeVar add QMAKE_CFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
-        QMakeVar add QMAKE_CXXFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
-        QMakeVar add QMAKE_LFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
-        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86_64 "-arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5"
+        QMakeVar add QMAKE_CFLAGS "-Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_CXXFLAGS "-Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_LFLAGS "-Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86_64 "-arch x86_64 -Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
     fi
     if echo "$CFG_MAC_ARCHS" | grep '\<ppc64\>' > /dev/null 2>&1; then
-        QMakeVar add QMAKE_CFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
-        QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
-        QMakeVar add QMAKE_LFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
-        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC_64 "-arch ppc64 -Xarch_ppc64 -mmacosx-version-min=10.5"
+        QMakeVar add QMAKE_CFLAGS "-Xarch_ppc64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_LFLAGS "-Xarch_ppc64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC_64 "-arch ppc64 -Xarch_ppc64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
     fi
 fi
 
@@ -8618,6 +8623,7 @@
 QMAKE_RCC        = \$\$QT_BUILD_TREE/bin/rcc
 QMAKE_QDBUSXML2CPP = \$\$QT_BUILD_TREE/bin/qdbusxml2cpp
 QMAKE_INCDIR_QT  = \$\$QT_BUILD_TREE/include
+QMAKE_FRAMEWORKDIR_QT = \$\$QT_BUILD_TREE/Library/Frameworks
 QMAKE_LIBDIR_QT  = \$\$QT_BUILD_TREE/lib
 
 EOF
