class Autobuild::Autotools

Handles autotools-based packages

Used programs (see Autobuild.programs)

Autotools will use the 'aclocal', 'autoheader', 'autoconf' and 'automake' 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 #use

Attributes

configureflags[RW]
force_config_status[RW]

If set to true, configure will be called with –no-create and ./config.status will be started each time before “make”

In general, you should not need that.

using[RW]

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/autobuild/packages/autotools.rb, line 36
def initialize(options)
    @using = Hash.new
    @configureflags = []
    
    super
end

Public Instance Methods

configurestamp() click to toggle source
# File lib/autobuild/packages/autotools.rb, line 34
def configurestamp; "#{builddir}/config.status" end
import() click to toggle source
Calls superclass method
# File lib/autobuild/packages/autotools.rb, line 117
def import
    # We force a regen after the first checkout. The issue is that
    # autotools is less robust than it should, and very often it is
    # better to generate the build system for the system on which we
    # must build
    #
    # When we are doing a fresh checkout, a file is touched in the
    # source directory. That file is then deleted after #prepare gets
    # called
    is_checking_out = !File.directory?(srcdir)

    super

ensure
    if is_checking_out && File.directory?(srcdir)
        FileUtils.touch File.join(srcdir, ".fresh_checkout")
    end
end
prepare() click to toggle source
Calls superclass method Autobuild::Configurable#prepare
# File lib/autobuild/packages/autotools.rb, line 136
def prepare
    super
    autodetect_needed_stages

    fresh_checkout_mark = File.join(srcdir, '.fresh_checkout')
    if File.file?(fresh_checkout_mark)
        prepare_for_forced_build
        FileUtils.rm_f fresh_checkout_mark
    end

    # Check if config.status has been generated with the
    # same options than the ones in configureflags
    #
    # If it is not the case, remove it to force reconfiguration
    configureflags.flatten!
    force_reconfigure = false
    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 do |o|
            if testflags.include?(o)
                false
            else
                name, value = o.split("=")
                ENV[name] != value
            end
        end
        new_opt = testflags.find { |o| !options.include?(o) }
        if old_opt || new_opt
            if Autobuild.verbose
                Autobuild.message "forcing reconfiguration of #{name} (#{old_opt} != #{new_opt})"
            end
            FileUtils.rm_f configurestamp # to force reconfiguration
        end
    end

    regen_target = create_regen_target
    file configurestamp => regen_target
end
prepare_for_forced_build() click to toggle source
# File lib/autobuild/packages/autotools.rb, line 98
def prepare_for_forced_build
    super

    autodetect_needed_stages
    if using[:autoconf] || using[:autogen]
        FileUtils.rm_f File.join(srcdir, 'configure')
    end

    if using[:automake]
        Find.find(srcdir) do |path|
            if File.basename(path) == "Makefile.in"
                FileUtils.rm_f path
            end
        end
    end

    FileUtils.rm_f configurestamp
end
use(*programs) click to toggle source

Overrides the default behaviour w.r.t. autotools script generation

Use it like that:

  • to force a generation step (skipping autodetection), do

    pkg.use <program> => true
    

    For instance, for aclocal

    pkg.use :aclocal => true
    
  • to force a generation step, overriding the program defined on Autobuild

    pkg.use <program> => true
    

    For instance, for autoconf

    pkg.use :autoconf => 'my_autoconf_program'
    
  • to disable a generation step, do

    pkg.use <program> => false
    

    For instance, for automake

    pkg.use :automake => false
    
  • to restore autodetection, do

    pkg.use <program> => nil
    

    For instance, for automake

    pkg.use :automake => nil
    
# File lib/autobuild/packages/autotools.rb, line 77
def use(*programs)
    programs =
        if programs.size == 1
            programs.first
        else
            programs
        end

    if !programs.kind_of?(Hash)
        programs = Array[*programs].inject({}) do |programs, spec|
            programs[spec.first] = spec.last
            programs
        end
    end
    programs.each do |name, opt|
        using[name.to_sym] = opt
    end

    nil
end
with_doc(target = 'doc') { || ... } click to toggle source

Declare that the given target can be used to generate documentation

# File lib/autobuild/packages/autotools.rb, line 44
def with_doc(target = 'doc')
    task "#{name}-doc" => configurestamp
    doc_task do
        progress_start "generating documentation for %s", :done_message => 'generated_documentation for %s' do
            Subprocess.run(self, 'doc', Autobuild.tool(:make), "-j#{parallel_build_level}", target, :working_directory => builddir)
        end
        yield if block_given?
    end
end