lib/autobuild/packages/autotools.rb in autobuild-0.3 vs lib/autobuild/packages/autotools.rb in autobuild-0.4

- old
+ new

@@ -39,14 +39,16 @@ (new.nil? || (new.respond_to?(:empty) && new.empty?)) ? old : new } super(target, options) @builddir = options[:builddir] - raise ConfigException, "Autotools packages need a non-empty builddir" if (@builddir.nil? || @builddir.empty?) - raise ConfigException, "No support for absolute builddirs" if (Pathname.new(@builddir).absolute?) + raise ConfigException, "autotools packages need a non-empty builddir" if (@builddir.nil? || @builddir.empty?) + raise ConfigException, "absolute builddirs are unsupported" if (Pathname.new(@builddir).absolute?) @builddir = File.expand_path(builddir, srcdir) + end + def prepare regen_targets file "#{builddir}/config.status" => "#{srcdir}/configure" do configure end @@ -70,46 +72,52 @@ def regen_targets conffile = "#{srcdir}/configure" if File.exists?("#{conffile}.ac") file conffile => [ "#{conffile}.ac" ] - else + elsif File.exists?("#{conffile}.in") file conffile => [ "#{conffile}.in" ] + else + raise PackageException.new(target), "neither configure.ac nor configure.in present in #{srcdir}" end file conffile do Dir.chdir(srcdir) { - $PROGRAMS['aclocal'] ||= 'aclocal' - $PROGRAMS['autoconf'] ||= 'autoconf' - $PROGRAMS['autoheader'] ||= 'autoheader' - $PROGRAMS['automake'] ||= 'automake' + $PROGRAMS[:aclocal] ||= 'aclocal' + $PROGRAMS[:autoconf] ||= 'autoconf' + $PROGRAMS[:autoheader] ||= 'autoheader' + $PROGRAMS[:automake] ||= 'automake' begin - # Autodetect autoconf/aclocal/automake - if @options[:autoconf].nil? - @options[:autoconf] = - File.exists?(File.join(srcdir, 'configure.in')) || - File.exists?(File.join(srcdir, 'configure.ac')) - end - @options[:aclocal] ||= @options[:autoconf] - if @options[:automake].nil? - @options[:automake] = File.exists?(File.join(srcdir, 'Makefile.am')) - end + if @options[:autogen] + subcommand(target, 'configure', File.expand_path(@options[:autogen])) + else + # Autodetect autoconf/aclocal/automake + if @options[:autoconf].nil? + @options[:autoconf] = + File.exists?(File.join(srcdir, 'configure.in')) || + File.exists?(File.join(srcdir, 'configure.ac')) + end + @options[:aclocal] ||= @options[:autoconf] + if @options[:automake].nil? + @options[:automake] = File.exists?(File.join(srcdir, 'Makefile.am')) + end - subcommand(target, 'configure', $PROGRAMS['aclocal']) if @options[:aclocal] - subcommand(target, 'configure', $PROGRAMS['autoconf']) if @options[:autoconf] - subcommand(target, 'configure', $PROGRAMS['autoheader']) if @options[:autoheader] - subcommand(target, 'configure', $PROGRAMS['automake']) if @options[:automake] + subcommand(target, 'configure', $PROGRAMS[:aclocal]) if @options[:aclocal] + subcommand(target, 'configure', $PROGRAMS[:autoconf]) if @options[:autoconf] + subcommand(target, 'configure', $PROGRAMS[:autoheader]) if @options[:autoheader] + subcommand(target, 'configure', $PROGRAMS[:automake]) if @options[:automake] + end rescue SubcommandFailed => e raise BuildException.new(e), "failed to build the configure environment of #{target}" end } end end def configure if File.exists?(builddir) && !File.directory?(builddir) - raise BuildException, "#{builddir} already exists but is not a directory" + raise ConfigException, "#{builddir} already exists but is not a directory" end FileUtils.mkdir_p builddir if !File.directory?(builddir) Dir.chdir(builddir) { command = [ "#{srcdir}/configure", "--no-create", "--prefix=#{prefix}" ] @@ -146,7 +154,6 @@ end } touch_stamp(installstamp) end end -