Index: trunk/Config.kmk
===================================================================
--- trunk/Config.kmk	(revision 53375)
+++ trunk/Config.kmk	(revision 53376)
@@ -1976,7 +1976,20 @@
 #
 ifeq ($(KBUILD_TARGET),darwin)
+ VBOX_DEF_MACOSX_VERSION_MIN ?= 10.6
+
+ # Check for the Xcode 4.1 bits in tools/darwin.x86.
+ if   !defined(VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL) \
+   && !defined(VBOX_XCODE_VERSION) \
+   && exists "$(PATH_DEVTOOLS)/darwin.x86/xcode/v4.1"
+  VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL := 1
+  VBOX_PATH_MACOSX_DEVEL_ROOT := $(PATH_DEVTOOLS)/darwin.x86/xcode/v4.1
+  VBOX_XCODE_VERSION := 4.1
+ endif
+
+ # Fallback - system / LocalConfig.kmk.
  VBOX_PATH_MACOSX_DEVEL_ROOT ?= /Developer
  VBOX_PATH_MACOSX_SDK_ROOT ?= $(VBOX_PATH_MACOSX_DEVEL_ROOT)/SDKs
 
+ # Figure the default SDK location and obsolete linker tricks.
  ifeq ($(VBOX_DEF_MACOSX_VERSION_MIN),10.4)
   ifeq ($(origin VBOX_DARWIN_CLASSIC_LINKER),undefined)
@@ -2014,5 +2027,4 @@
  VBOX_XCODE_VERSION       := $(VBOX_XCODE_VERSION_MAJOR).$(VBOX_XCODE_VERSION_MINOR)
 
- VBOX_DEF_MACOSX_VERSION_MIN ?= 10.6
  ifeq ($(KBUILD_TARGET_ARCH),x86)
   if1of ($(VBOX_DEF_MACOSX_VERSION_MIN), 10.4 10.5)
Index: trunk/tools/darwin.x86/bin/xcode-4.1-extrator.sh
===================================================================
--- trunk/tools/darwin.x86/bin/xcode-4.1-extrator.sh	(revision 53376)
+++ trunk/tools/darwin.x86/bin/xcode-4.1-extrator.sh	(revision 53376)
@@ -0,0 +1,179 @@
+#!/bin/bash
+# $Id$
+## @file
+# Extracts the necessary bits from the Xcode 4.1 lion package (inside installercode_41_lion.dmg).
+
+#
+# Copyright (C) 2014 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+#
+# Make sure we're talking the same language.
+#
+LC_ALL=C
+export LC_ALL
+
+#
+# Figure the tools/darwin.x86 location.
+#
+MY_DARWIN_DIR=`dirname "$0"`
+MY_DARWIN_DIR=`(cd "${MY_DARWIN_DIR}" ; pwd)`
+MY_DARWIN_DIR=`dirname "${MY_DARWIN_DIR}"`
+
+#
+# Constants.
+#
+MY_PKGS="gcc4.2.pkg llvm-gcc4.2.pkg DeveloperToolsCLI.pkg xcrun.pkg JavaSDK.pkg MacOSX10.6.pkg MacOSX10.7.pkg"
+declare -a MY_FULL_PKGS
+for i in $MY_PKGS;  
+do 
+    MY_FULL_PKGS[$((${#MY_FULL_PKGS[*]}))]="./Applications/Install Xcode.app/Contents/Resources/Packages/${i}"
+done
+
+#
+# Parse arguments.
+#
+MY_TMP_DIR=/var/tmp/xcode41extractor
+MY_DST_DIR="${MY_DARWIN_DIR}/xcode/v41"
+MY_PKG_FILE=
+
+my_usage()
+{
+    echo "usage: $0 [--tmpdir|-t <tmpdir>]  <--destination|-d> <dstdir>  <--filename|-f> <dir/InstallXcodeLion.pkg>";
+    exit $1;
+}
+
+while test $# -ge 1;
+do
+    ARG=$1;
+    shift;
+    case "$ARG" in
+
+        --tmpdir|-t)
+            if test $# -eq 0; then
+                echo "error: missing --tmpdir argument." 1>&2;
+                exit 1;
+            fi
+            MY_TMP_DIR="$1";
+            shift;
+            ;;
+        
+        --destination|-d)
+            if test $# -eq 0; then
+                echo "error: missing --tmpdir argument." 1>&2;
+                exit 1;
+            fi
+            MY_DST_DIR="$1";
+            shift;
+            ;;
+
+        --filename|-f)
+            if test $# -eq 0; then
+                echo "error: missing --filename argument." 1>&2;
+                exit 1;
+            fi
+            MY_PKG_FILE="$1";
+            shift;
+            ;;
+
+        --h*|-h*|-?|--?)
+            my_usage 0;
+    esac
+done
+
+# Check the package file.
+if [ -z "${MY_PKG_FILE}" ]; then
+    echo "error: missing --filename <dir/InstallXcodeLion.pkg>." 1>&2l
+    my_usage 1;
+fi
+if ! xar -tf "${MY_PKG_FILE}" > /dev/null ; then
+    echo "error: xar has trouble with '${MY_PKG_FILE}'." 1>&2;
+    exit 1;
+fi
+
+# Check the destination directory.
+if [ -z "${MY_DST_DIR}" ]; then
+    echo "error: missing --destination <dstdir>." 1>&2;
+    my_usage 1;
+fi
+if ! mkdir -p "${MY_DST_DIR}"; then 
+    echo "error: error creating '${MY_DST_DIR}'." 1>&2;
+    exit 1;
+fi
+
+# Check the temporary directory.
+if [ -z "${MY_TMP_DIR}" ]; then
+    echo "error: empty --tmpdir <tmpdir>." 1>&2;
+    my_usage 1;
+fi
+if ! mkdir -p "${MY_TMP_DIR}/x"; then 
+    echo "error: error creating '${MY_TMP_DIR}/x'." 1>&2;
+    exit 1;
+fi
+
+#
+# Extract the "Applications/Install Xcode.app" payload, calling it MainPayload.tar.
+#
+if [ ! -f "${MY_TMP_DIR}/x/MainPayload.tar" ]; then
+    echo "info: Extracting '${MY_PKG_FILE}'..."
+    if ! xar -xvf "${MY_PKG_FILE}" -C "${MY_TMP_DIR}/x"; then 
+        echo "error: extraction error." 1>&2;
+        exit 1;
+    fi
+    if ! mv -f "${MY_TMP_DIR}/x/InstallXcodeLion.pkg/Payload" "${MY_TMP_DIR}/x/MainPayload.tar"; then
+        echo "error: Failed to move the package payload. Did you get the right package file?" 1>&2;
+        exit 1;
+    fi
+fi
+
+#
+# Extract the sub-packages from MainPayload.tar. Make sure MacOSX10.7.pkg is the last.
+#
+if [ ! -f "${MY_TMP_DIR}/x/MacOSX10.7.pkg" ]; then
+    echo "info: Extracting packages from 'MainPayload.tar'..."
+    if ! tar xvf "${MY_TMP_DIR}/x/MainPayload.tar" -C "${MY_TMP_DIR}/x" "${MY_FULL_PKGS[@]}"; then 
+        echo "error: Failure extracting sub-packages from MainPayload.tar (see above)." 1>&2;
+        exit 1;
+    fi
+
+    for i in $MY_PKGS;  
+    do
+        if ! mv -f "${MY_TMP_DIR}/x/Applications/Install Xcode.app/Contents/Resources/Packages/${i}" "${MY_TMP_DIR}/x/${i}"; then 
+            echo "error: Failed to move the package ${i}." 1>&2;
+            exit 1;
+        fi
+    done    
+fi
+
+#
+# Work the sub-packages, extracting their payload content into the destination directory.
+#
+for i in $MY_PKGS;  
+do
+    rm -f -- "${MY_TMP_DIR}/x/Payload";
+    echo "info: Extracting payload of sub-package ${i}...";
+    if ! xar -xvf "${MY_TMP_DIR}/x/${i}" -C "${MY_TMP_DIR}/x" Payload; then 
+        echo "error: Failed to extract the payload of sub-package ${i}." 1>&2;
+        exit 1;
+    fi
+    if ! tar xvf "${MY_TMP_DIR}/x/Payload" -C "${MY_DST_DIR}"; then 
+        echo "error: Failed to extract the payload content of sub-package ${i}." 1>&2;
+        exit 1;
+    fi
+done    
+
+#
+# Clean up.
+#
+echo "info: Successfully extracted. Cleaning up temporary files..."
+rm -Rf -- "${MY_TMP_DIR}/x/"
+rmdir -- "${MY_TMP_DIR}"
+
