Method: Autobuild.ensure_gnumake_detected

Defined in:
lib/autobuild/packages/gnumake.rb

.ensure_gnumake_detected(pkg, path = Autobuild.tool(:make)) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/autobuild/packages/gnumake.rb', line 7

def self.ensure_gnumake_detected(pkg, path = Autobuild.tool(:make))
    @make_is_gnumake ||= Hash.new
    @gnumake_version ||= Hash.new
    return @make_is_gnumake[path] if @make_is_gnumake.key?(path)

    begin
        gnumake_version_string = pkg.run('prepare', path, '--version')
    rescue Autobuild::SubcommandFailed
        @make_is_gnumake[path] = false
        return
    end

    gnumake_match = /^GNU Make[^\d]+(\d[\d.]+)/.match(gnumake_version_string.first)
    unless gnumake_match
        @make_is_gnumake[path] = false
        return
    end

    @gnumake_version[path] = Gem::Version.new(gnumake_match[1])
    @make_is_gnumake[path] = true
end