class PackageConfig

def guess_default_path

def guess_default_path
  arch_depended_path = Dir.glob('/usr/lib/*/pkgconfig').join(SEPARATOR)
  default_paths = [
    "/usr/local/lib64/pkgconfig",
    "/usr/local/lib/pkgconfig",
    "/usr/local/libdata/pkgconfig",
    "/opt/local/lib/pkgconfig",
    arch_depended_path,
    "/usr/lib64/pkgconfig",
    "/usr/lib/pkgconfig",
    "/usr/libdata/pkgconfig",
    "/usr/X11/lib/pkgconfig",
    "/opt/X11/lib/pkgconfig",
    "/usr/share/pkgconfig",
  ]
  default_path = default_paths.join(SEPARATOR)
  libdir = ENV["PKG_CONFIG_LIBDIR"]
  default_path = [libdir, default_path].join(SEPARATOR) if libdir
  pkg_config = self.class.native_pkg_config
  return default_path unless pkg_config.absolute?
  pkg_config_prefix = pkg_config.parent.parent
  pkg_config_arch_depended_path =
    Dir.glob((pkg_config_prefix + "lib/*/pkgconfig").to_s).join(SEPARATOR)
  [pkg_config_arch_depended_path,
   (pkg_config_prefix + "lib64/pkgconfig").to_s,
   (pkg_config_prefix + "lib/pkgconfig").to_s,
   (pkg_config_prefix + "libdata/pkgconfig").to_s,
   default_path].join(SEPARATOR)
end