Parent

Archiver

The archiver creates a static library from one or more object files

Attributes

objects[RW]
output[RW]
path[R]
ranlib[R]

Public Class Methods

new(output = nil, objects = []) click to toggle source
# File lib/makeconf/archiver.rb, line 8
def initialize(output = nil, objects = [])
  @flags = 'cru'      # GNU-specific; more portable is 'rcs'
  @output = output
  @objects = objects
  @path = nil

  if ENV['LD']
    self.path = ENV['LD']
  else
    self.path = 'ar'
  end

  if ENV['RANLIB']
    @ranlib = ENV['RANLIB']
  else
    @ranlib = 'ranlib'
  end
end

Public Instance Methods

command() click to toggle source
# File lib/makeconf/archiver.rb, line 43
def command
  cmd = [ '$(AR)', @flags, @output, @objects].flatten.join(' ')
  log.debug "Archiver command = `#{cmd}'"
  cmd
end
makefile() click to toggle source
# File lib/makeconf/archiver.rb, line 36
def makefile
  m = Makefile.new
  m.define_variable('AR', '=', @path)
  m.define_variable('RANLIB', '=', @ranlib)
  return m
end
path=(p) click to toggle source

Set the full path to the archiver executable

# File lib/makeconf/archiver.rb, line 28
  def path=(p)
    @path = p
    # TODO: Support non-GNU archivers
    #if `#{@path} --version` =~ /^GNU ar/
#  @gcc_flags = false
#    end
  end
to_make() click to toggle source

Return the command formatted as a Makefile rule

# File lib/makeconf/archiver.rb, line 50
def to_make
  Target.new(@output, @objects, [
          Target::ConditionalRule.new([command, "$(RANLIB) #{output}"]).ifneq('$(DISABLE_STATIC)','1')
          ])
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.