From 9ebc527e49e531a240aa628659b00df56158ebf7 Mon Sep 17 00:00:00 2001
From: Mike McQuaid <mike@mikemcquaid.com>
Date: Wed, 23 Oct 2013 17:44:43 +0100
Subject: [PATCH] Improve Xcode and CLT installation instructions.

---
 Library/Homebrew/blacklist.rb    | 14 +++++---
 Library/Homebrew/cmd/doctor.rb   | 62 ++++++++++++++++++++++++--------
 Library/Homebrew/requirements.rb | 35 +++++++++++++-----
 3 files changed, 85 insertions(+), 26 deletions(-)

diff --git a/Library/Homebrew/blacklist.rb b/Library/Homebrew/blacklist.rb
index 958c4154c6..4f981fa8ba 100644
--- a/Library/Homebrew/blacklist.rb
+++ b/Library/Homebrew/blacklist.rb
@@ -40,10 +40,16 @@ def blacklisted? name
     EOS
   when /(lib)?lzma/
     "lzma is now part of the xz formula."
-  when 'xcode' then <<-EOS.undent
-    Xcode can be installed via the App Store (on Lion or newer), or from:
-      https://developer.apple.com/downloads/
-    EOS
+  when 'xcode'
+    if MacOS.version >= :lion
+      <<-EOS.undent
+      Xcode can be installed from the App Store.
+      EOS
+    else
+      <<-EOS.undent
+      Xcode can be installed from https://developer.apple.com/downloads/
+      EOS
+    end
   when 'gtest', 'googletest', 'google-test' then <<-EOS.undent
     Installing gtest system-wide is not recommended; it should be vendored
     in your projects that use it.
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 059e6f2840..47ad62027b 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -193,34 +193,68 @@ end
 def check_xcode_clt
   if MacOS::Xcode.installed?
     __check_xcode_up_to_date
-  elsif MacOS.version >= "10.7"
+  elsif MacOS.version >= :lion
     __check_clt_up_to_date
   else <<-EOS.undent
-    Xcode not installed
-    Most stuff needs Xcode to build: http://developer.apple.com/xcode/
+      Xcode is not installed
+      Most formulae need Xcode to build.
+      It can be installed from https://developer.apple.com/downloads/
     EOS
   end
 end
 
 def __check_xcode_up_to_date
-  if MacOS::Xcode.outdated? then <<-EOS.undent
-    Your Xcode (#{MacOS::Xcode.version}) is outdated
-    Please install Xcode #{MacOS::Xcode.latest_version}.
+  if MacOS::Xcode.outdated?
+    message = <<-EOS.undent
+      Your Xcode (#{MacOS::Xcode.version}) is outdated
+      Please update to Xcode #{MacOS::Xcode.latest_version}.
     EOS
+    if MacOS.version >= :lion
+      message += <<-EOS.undent
+      Xcode can be updated from the App Store.
+      EOS
+    else
+      message += <<-EOS.undent
+      Xcode can be updated from https://developer.apple.com/downloads/
+      EOS
+    end
+    message
   end
 end
 
 def __check_clt_up_to_date
-  if not MacOS::CLT.installed? then <<-EOS.undent
-    No developer tools installed
-    You should install the Command Line Tools:
-      https://developer.apple.com/downloads/
+  if not MacOS::CLT.installed?
+    message = <<-EOS.undent
+      No developer tools installed.
+      You should install the Command Line Tools.
     EOS
-  elsif MacOS::CLT.outdated? then <<-EOS.undent
-    A newer Command Line Tools release is available
-    You should install the latest version from:
-      https://developer.apple.com/downloads
+    if MacOS.version >= :mavericks
+      message += <<-EOS.undent
+        Run `xcode-select --install` to install them.
+      EOS
+    else
+      message += <<-EOS.undent
+        The standalone package can be obtained from
+        https://developer.apple.com/downloads/,
+        or it can be installed via Xcode's preferences.
+      EOS
+    end
+    message
+  elsif MacOS::CLT.outdated?
+    message = <<-EOS.undent
+      A newer Command Line Tools release is available
     EOS
+    if MacOS.version >= :mavericks
+      message += <<-EOS.undent
+        Update them from Software Update in the App Store.
+      EOS
+    else
+      message += <<-EOS.undent
+        The standalone package can be obtained from
+        https://developer.apple.com/downloads/,
+        or it can be installed via Xcode's preferences.
+      EOS
+    end
   end
 end
 
diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index b195af98e1..73e0860b76 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -12,10 +12,20 @@ class XcodeDependency < Requirement
 
   satisfy(:build_env => false) { MacOS::Xcode.installed? }
 
-  def message; <<-EOS.undent
-    A full installation of Xcode.app is required to compile this software.
-    Installing just the Command Line Tools is not sufficient.
+  def message
+    message = <<-EOS.undent
+      A full installation of Xcode.app is required to compile this software.
+      Installing just the Command Line Tools is not sufficient.
     EOS
+    if MacOS.version >= :lion
+      message += <<-EOS.undent
+        Xcode can be installed from the App Store.
+      EOS
+    else
+      message += <<-EOS.undent
+        Xcode can be installed from https://developer.apple.com/downloads/
+      EOS
+    end
   end
 end
 
@@ -58,12 +68,21 @@ class CLTDependency < Requirement
 
   satisfy(:build_env => false) { MacOS::CLT.installed? }
 
-  def message; <<-EOS.undent
-    The Command Line Tools are required to compile this software.
-    The standalone package can be obtained from
-    https://developer.apple.com/downloads/,
-    or it can be installed via Xcode's preferences.
+  def message
+    message = <<-EOS.undent
+      The Command Line Tools are required to compile this software.
     EOS
+    if MacOS.version >= :mavericks
+      message += <<-EOS.undent
+        Run `xcode-select --install` to install them.
+      EOS
+    else
+      message += <<-EOS.undent
+        The standalone package can be obtained from
+        https://developer.apple.com/downloads/,
+        or it can be installed via Xcode's preferences.
+      EOS
+    end
   end
 end
 
-- 
GitLab