lib/autobuild/packages/autotools.rb in autobuild-1.4.9 vs lib/autobuild/packages/autotools.rb in autobuild-1.5.0

- old
+ new

@@ -19,47 +19,25 @@ # programs defined on Autobuild.programs. autoheader is disabled by default, # aclocal, autoconf and automake use are autodetected. # # To override this default behaviour on a per-package basis, use Autotools#use # - class Autotools < Package + class Autotools < Configurable attr_accessor :using attr_accessor :configureflags - class << self - attr_reader :builddir - def builddir=(new) - raise ConfigException, "absolute builddirs are not supported" if (Pathname.new(new).absolute?) - raise ConfigException, "builddir must be non-nil and non-empty" if (new.nil? || new.empty?) - @builddir = new - end - end + @builddir = 'build' - def builddir=(new) - raise ConfigException, "absolute builddirs are not supported" if (Pathname.new(new).absolute?) - raise ConfigException, "builddir must be non-empty" if new.empty? - @builddir = new - end - # Returns the absolute builddir - def builddir; File.expand_path(@builddir || Autotools.builddir, srcdir) end + def configurestamp; "#{builddir}/config.status" end - # Build stamp - # This returns the name of the file which marks when the package has been - # successfully built for the last time. The path is absolute - def buildstamp; "#{builddir}/#{STAMPFILE}" end - def initialize(options) @using = Hash.new @configureflags = [] super end - def install_doc(relative_to = builddir) - super(relative_to) - end - # Declare that the given target can be used to generate documentation def with_doc(target = 'doc') doc_task do Dir.chdir(builddir) do progress "generating documentation for %s" @@ -105,70 +83,40 @@ end nil end - def depends_on(*packages) - super - stamps = packages.collect { |p| Package[p.to_s].installstamp } - file "#{builddir}/config.status" => stamps - end - - def ensure_dependencies_installed - dependencies.each do |pkg| - Rake::Task[Package[pkg].installstamp].invoke - end - end - def prepare super - configureflags.flatten! - # Check if config.status has been generated with the # same options than the ones in configureflags - config_status = "#{builddir}/config.status" - + # + # If it is not the case, remove it to force reconfiguration + configureflags.flatten! force_reconfigure = false - if File.exists?(config_status) - output = IO.popen("#{config_status} --version").readlines.grep(/with options/).first.chomp + if File.exists?(configurestamp) + output = IO.popen("#{configurestamp} --version").readlines.grep(/with options/).first.chomp raise "invalid output of config.status --version" unless output =~ /with options "(.*)"$/ options = Shellwords.shellwords($1) # Add the --prefix option to the configureflags array testflags = ["--prefix=#{prefix}"] + Array[*configureflags] old_opt = options.find { |o| !testflags.include?(o) } new_opt = testflags.find { |o| !options.include?(o) } if old_opt || new_opt - FileUtils.rm_f config_status # to force reconfiguration + FileUtils.rm_f configurestamp # to force reconfiguration end end - file config_status => regen do - ensure_dependencies_installed - configure - end - - Autobuild.source_tree srcdir do |pkg| - pkg.exclude << Regexp.new("^#{Regexp.quote(builddir)}") - end - file buildstamp => [ srcdir, "#{builddir}/config.status" ] do - ensure_dependencies_installed - build - end - task "#{name}-build" => installstamp - - file installstamp => buildstamp do - install - end - - Autobuild.update_environment(prefix) + regen_target = create_regen_target + file configurestamp => regen_target end private # Adds a target to rebuild the autotools environment - def regen(confsource = nil) + def create_regen_target(confsource = nil) conffile = "#{srcdir}/configure" if confsource file conffile => confsource elsif confext = %w{.ac .in}.find { |ext| File.exists?("#{conffile}#{ext}") } file conffile => "#{conffile}#{confext}" @@ -204,31 +152,35 @@ end Subprocess.run(self, 'configure', tool_program) end end + + if using[:libtool].nil? + using[:libtool] = File.exists?(File.join(srcdir, 'ltmain.sh')) + end + if using[:libtool] + Subprocess.run(self, 'configure', Autobuild.tool('libtoolize'), '--copy') + end end end end return conffile end # Configure the builddir directory before starting make def configure - if File.exists?(builddir) && !File.directory?(builddir) - raise ConfigException, "#{builddir} already exists but is not a directory" + super do + Dir.chdir(builddir) do + command = [ "#{srcdir}/configure", "--no-create", "--prefix=#{prefix}" ] + command += Array[*configureflags] + + progress "configuring build system for %s" + Subprocess.run(self, 'configure', *command) + end end - - FileUtils.mkdir_p builddir if !File.directory?(builddir) - Dir.chdir(builddir) { - command = [ "#{srcdir}/configure", "--no-create", "--prefix=#{prefix}" ] - command += Array[*configureflags] - - progress "configuring build system for %s" - Subprocess.run(self, 'configure', *command) - } end # Do the build in builddir def build Dir.chdir(builddir) do @@ -243,11 +195,11 @@ def install Dir.chdir(builddir) do progress "installing %s" Subprocess.run(self, 'install', Autobuild.tool(:make), "-j#{parallel_build_level}", 'install') end - Autobuild.touch_stamp(installstamp) - Autobuild.update_environment(prefix) + + super end end end