blob: d37e778ca53f3e2cd07b1b3a1947b6ba3658bf8c (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
 | require "os/mac/xcode"
# @private
class DevelopmentTools
  class << self
    alias original_locate locate
    def locate(tool)
      (@locate ||= {}).fetch(tool) do |key|
        @locate[key] = if (located_tool = original_locate(tool))
          located_tool
        elsif MacOS.version > :tiger
          path = Utils.popen_read("/usr/bin/xcrun", "-no-cache", "-find", tool, err: :close).chomp
          Pathname.new(path) if File.executable?(path)
        end
      end
    end
    # Checks if the user has any developer tools installed, either via Xcode
    # or the CLT. Convenient for guarding against formula builds when building
    # is impossible.
    def installed?
      MacOS::Xcode.installed? || MacOS::CLT.installed?
    end
    def installation_instructions
      if MacOS.version >= "10.9"
        <<~EOS
          Install the Command Line Tools:
            xcode-select --install
        EOS
      elsif MacOS.version == "10.8" || MacOS.version == "10.7"
        <<~EOS
          Install the Command Line Tools from
            https://developer.apple.com/download/more/
          or via Xcode's preferences.
        EOS
      else
        <<~EOS
          Install Xcode from
            https://developer.apple.com/download/more/
        EOS
      end
    end
    def custom_installation_instructions
      if MacOS.version > :leopard
        <<~EOS
          Install GNU's GCC
            brew install gcc
        EOS
      elsif MacOS.version > :tiger
        <<~EOS
          Install GNU's GCC
            brew install gcc@4.6
        EOS
      else
        # Tiger doesn't ship with apple-gcc42, and this is required to build
        # some software that doesn't build properly with FSF GCC.
        <<~EOS
          Install Apple's GCC
            brew install apple-gcc42
          or GNU's GCC
            brew install gcc@4.6
        EOS
      end
    end
    def default_compiler
      case default_cc
      # if GCC 4.2 is installed, e.g. via Tigerbrew, prefer it
      # over the system's GCC 4.0
      when /^gcc-4\.0/ then gcc_4_2_build_version ? :gcc_4_2 : :gcc_4_0
      when /^gcc/ then :gcc_4_2
      when "clang" then :clang
      else
        # guess :(
        if MacOS::Xcode.version >= "4.3"
          :clang
        else
          :gcc_4_2
        end
      end
    end
    def curl_handles_most_https_certificates?
      # The system Curl is too old for some modern HTTPS certificates on
      # older macOS versions.
      ENV["HOMEBREW_SYSTEM_CURL_TOO_OLD"].nil?
    end
    def subversion_handles_most_https_certificates?
      # The system Subversion is too old for some HTTPS certificates on
      # older macOS versions.
      MacOS.version >= :sierra
    end
  end
end
 |