# module PKGConfig

### Constants

VERSION

### Public Instance Methods

add_path(path) click to toggle source

    # File lib/pkg-config.rb, line 28
    def add_path(path)
      @@paths << path
    end

cflags(pkg) click to toggle source

    # File lib/pkg-config.rb, line 63
    def cflags(pkg)
      package_config(pkg).cflags
    end

cflags_only_I(pkg) click to toggle source

    # File lib/pkg-config.rb, line 67
    def cflags_only_I(pkg)
      package_config(pkg).cflags_only_I
    end

cflags_only_other(pkg) click to toggle source

    # File lib/pkg-config.rb, line 71
    def cflags_only_other(pkg)
      package_config(pkg).cflags_only_other
    end

check_version?(pkg, major=0, minor=0, micro=0) click to toggle source

    # File lib/pkg-config.rb, line 87
    def check_version?(pkg, major=0, minor=0, micro=0)
      return false unless exist?(pkg)
      ver = modversion(pkg).split(".").collect {|item| item.to_i}
      (0..2).each {|i| ver[i] = 0 unless ver[i]}

      (ver[0] > major ||
       (ver[0] == major && ver[1] > minor) ||
       (ver[0] == major && ver[1] == minor &&
        ver[2] >= micro))
    end

description(pkg) click to toggle source

    # File lib/pkg-config.rb, line 79
    def description(pkg)
      package_config(pkg).description
    end

exist?(pkg) click to toggle source

    # File lib/pkg-config.rb, line 47
    def exist?(pkg)
      package_config(pkg).exist?
    end

have_package(pkg, major=nil, minor=0, micro=0) click to toggle source

    # File lib/pkg-config.rb, line 98
    def have_package(pkg, major=nil, minor=0, micro=0)
      message = "#{pkg}"
      unless major.nil?
        message << " version (>= #{major}.#{minor}.#{micro})"
      end
      major ||= 0
      result = checking_for(checking_message(message), "%s") do
        if check_version?(pkg, major, minor, micro)
          "yes (#{modversion(pkg)})"
        else
          if exist?(pkg)
            "no (#{modversion(pkg)})"
          else
            "no (nonexistent)"
          end
        end
      end
      enough_version = result.start_with?("yes")
      if enough_version
        libraries = libs_only_l(pkg)
        dldflags = libs(pkg)
        dldflags = (Shellwords.shellwords(dldflags) -
                    Shellwords.shellwords(libraries))
        dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(" ")
        $libs   += " " + libraries
        if /mswin/ =~ RUBY_PLATFORM
          $DLDFLAGS += " " + dldflags
        else
          $LDFLAGS += " " + dldflags
        end
        $CFLAGS += " " + cflags_only_other(pkg)
        if defined?($CXXFLAGS)
          $CXXFLAGS += " " + cflags_only_other(pkg)
        end
        $INCFLAGS += " " + cflags_only_I(pkg)
      end
      enough_version
    end

libs(pkg) click to toggle source

    # File lib/pkg-config.rb, line 51
    def libs(pkg)
      package_config(pkg).libs
    end

libs_only_L(pkg) click to toggle source

    # File lib/pkg-config.rb, line 59
    def libs_only_L(pkg)
      package_config(pkg).libs_only_L
    end

libs_only_l(pkg) click to toggle source

    # File lib/pkg-config.rb, line 55
    def libs_only_l(pkg)
      package_config(pkg).libs_only_l
    end

modversion(pkg) click to toggle source

    # File lib/pkg-config.rb, line 75
    def modversion(pkg)
      package_config(pkg).version
    end

msvc?() click to toggle source

    # File lib/pkg-config.rb, line 36
    def msvc?
      /mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG["CC"])
    end

package_config(package) click to toggle source

    # File lib/pkg-config.rb, line 40
    def package_config(package)
      PackageConfig.new(package,
                        :msvc_syntax => msvc?,
                        :override_variables => @@override_variables,
                        :paths => @@paths)
    end

set_override_variable(key, value) click to toggle source

    # File lib/pkg-config.rb, line 32
    def set_override_variable(key, value)
      @@override_variables[key] = value
    end

variable(pkg, name) click to toggle source

    # File lib/pkg-config.rb, line 83
    def variable(pkg, name)
      package_config(pkg).variable(name)
    end