2 # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4 # See LICENSE.txt for permissions.
9 class Gem::Ext::Builder
12 name =~ /Ext::(.*)Builder/
16 def self.make(dest_path, results)
17 unless File.exist? 'Makefile' then
18 raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
21 mf = File.read('Makefile')
22 mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
23 mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
25 File.open('Makefile', 'wb') {|f| f.print mf}
27 make_program = ENV['make']
28 unless make_program then
29 make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
32 ['', ' install'].each do |target|
33 cmd = "#{make_program}#{target}"
35 results << `#{cmd} #{redirector}`
37 raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless
46 def self.run(command, results)
48 results << `#{command} #{redirector}`
50 unless $?.exitstatus.zero? then
51 raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}"