require 'build-tool/build-system/make' module BuildTool; module BuildSystem # # # class AutoConf < Base include MJ::Tools::SubProcess class AutoConfError < BuildTool::Error; end def intitialize( *args ) super( *args ) @supported_options << 'libdir' end # ### ATTRIBUTES # def name "autoconf" end # Check if the module is configured def configured? Pathname.new( build_directory ).join( 'Makefile' ).exist? end # ### METHODS # # Configure the module def reconfigure() configure end def install( fast ) make( "install" ) end def install_fast_supported? false end def bootstrap if File.exist?( "#{source_directory}/configure" ) return end logger.trace "Project has to be bootstrapped." if File.exist?( "#{source_directory}/Makefile.cvs" ) rc = self.class.execute "make -f Makefile.cvs", source_directory, env if rc != 0 raise AutoConfError, "'make -f Makefile.cvs' failed with error #{rc}!" end rc elsif File.exist?( "#{source_directory}/autogen.sh" ) rc = self.class.execute "sh ./autogen.sh", source_directory, env if rc != 0 raise AutoConfError, "'sh ./autogen.sh' failed with error #{rc}!" end rc elsif File.exist?( "#{source_directory}/bootstrap" ) rc = self.class.execute "sh ./bootstrap", source_directory, env if rc != 0 raise AutoConfError, "'sh ./bootstrap' failed with error #{rc}!" end rc else logger.trace "Trying autoconf. May fail!!" rc = self.class.execute "autoconf", source_directory, env if rc != 0 raise AutoConfError, "'autoconf' failed with error #{rc}!" end rc end end def configure check_build_directory( true ) bootstrap opt = option_string opt += " --prefix=#{install_prefix.to_s}" if install_prefix rc = self.class.execute "#{source_directory}/configure #{opt}", build_directory, env if rc != 0 raise AutoConfError, "configure failed with error #{rc}!" end rc end def install( fast ) make( "install" ) end def install_fast_supported? true end def make( target = nil ) Make.make( "#{target ? target : "" }", build_directory, self.module.environment.values ) end def option_string arr = [] option_names.each do |var| val = self[var] if val arr << "--#{var}='#{val}'" else arr << "--#{var}'" end end arr.join(" ") end end # class Autoconf end; end # module BuildTool::BuildSystem