Parent

PkgConfig

Generates a pkgconfig '.pc' file

Attributes

description[RW]
export_cflags[RW]
libs_private[RW]
name[RW]
requires[RW]
version[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/makeconf/pkgconfig.rb, line 7
def initialize(options = {})
  raise ArgumentError unless options.kind_of?(Hash)

  # pkgconfig variables
  @name = nil
  @description = 'No description'
  @version = '0.1'
  @requires = ''
  @libs_private = ''
  @export_cflags = ''

  options.each do |k,v|
    instance_variable_set('@' + k.to_s,v)
    # KLUDGE - parent constructor will barf unless we delete our 
    #       custom options
    options.delete k
  end

  super(options)
end

Public Instance Methods

compile(cc) click to toggle source
# File lib/makeconf/pkgconfig.rb, line 54
def compile(cc)
  input = @name + '.pc.in'
  output = @name + '.pc'
  mk = Makefile.new
  mk.add_target(output, [ 'config.h' ], [
          "@echo 'creating #{output}'",
          '@printf "prefix=$(PREFIX)\nexec_prefix=$(EPREFIX)\nlibdir=$(LIBDIR)\nincludedir=$(INCLUDEDIR)\n" > ' + output,
          "@cat #{@name}.pc.in >> #{output}"
          ])
  mk.distribute input

  mk.add_dependency('all',output)
  
  return mk
end
install(installer) click to toggle source
# File lib/makeconf/pkgconfig.rb, line 32
def install(installer)
  installer.install(
      :sources => @name + '.pc',
      :dest => '$(PKGCONFIGDIR)',
      :mode => '644') 
end
makedepends() click to toggle source
# File lib/makeconf/pkgconfig.rb, line 73
def makedepends
  []
end
makefile_hook(makefile) click to toggle source
# File lib/makeconf/pkgconfig.rb, line 28
def makefile_hook(makefile)
  makefile.define_variable('PKGCONFIGDIR', '=', '$(LIBDIR)/pkgconfig')
end
project_hook(proj) click to toggle source
# File lib/makeconf/pkgconfig.rb, line 39
def project_hook(proj)
  File.open("#{name}.pc.in", 'w') do |f|
     f.puts Name: #{@name}Description: #{@description}Version: #{@version}Requires: #{@requires}Libs: #{@libs}Libs.private: #{@libs_private}Cflags: #{@export_cflags}
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.