class PackageConfig
def guess_default_path
def guess_default_path arch_depended_path = Dir.glob("/usr/lib/*/pkgconfig") default_paths = [ "/usr/local/lib64/pkgconfig", "/usr/local/libx32/pkgconfig", "/usr/local/lib/pkgconfig", "/usr/local/libdata/pkgconfig", "/usr/local/share/pkgconfig", "/opt/local/lib/pkgconfig", *arch_depended_path, "/usr/lib64/pkgconfig", "/usr/libx32/pkgconfig", "/usr/lib/pkgconfig", "/usr/libdata/pkgconfig", "/usr/X11R6/lib/pkgconfig", "/usr/X11R6/share/pkgconfig", "/usr/X11/lib/pkgconfig", "/opt/X11/lib/pkgconfig", "/usr/share/pkgconfig", ] if Object.const_defined?(:RubyInstaller) mingw_bin_path = RubyInstaller::Runtime.msys2_installation.mingw_bin_path mingw_pkgconfig_path = Pathname.new(mingw_bin_path) + "../lib/pkgconfig" default_paths.unshift(mingw_pkgconfig_path.cleanpath.to_s) end libdir = ENV["PKG_CONFIG_LIBDIR"] default_paths.unshift(libdir) if libdir paths = [] pkg_config_prefix = self.class.native_pkg_config_prefix if pkg_config_prefix pkg_config_arch_depended_paths = Dir.glob((pkg_config_prefix + "lib/*/pkgconfig").to_s) paths.concat(pkg_config_arch_depended_paths) paths << (pkg_config_prefix + "lib64/pkgconfig").to_s paths << (pkg_config_prefix + "libx32/pkgconfig").to_s paths << (pkg_config_prefix + "lib/pkgconfig").to_s paths << (pkg_config_prefix + "libdata/pkgconfig").to_s end if /-darwin\d[\d\.]*\z/ =~ RUBY_PLATFORM and /\A(\d+\.\d+)/ =~ `sw_vers -productVersion` mac_os_version = $1 homebrew_repository_candidates = [] if pkg_config_prefix brew_path = pkg_config_prefix + "bin" + "brew" if brew_path.exist? escaped_brew_path = Shellwords.escape(brew_path.to_s) homebrew_repository = `#{escaped_brew_path} --repository`.chomp homebrew_repository_candidates << Pathname.new(homebrew_repository) else homebrew_repository_candidates << pkg_config_prefix + "Homebrew" homebrew_repository_candidates << pkg_config_prefix end end brew = self.class.__send__(:search_executable_from_path, "brew") if brew homebrew_repository = `brew --repository`.chomp homebrew_repository_candidates << Pathname(homebrew_repository) end homebrew_repository_candidates.uniq.each do |candidate| path = candidate + "Library/Homebrew/os/mac/pkgconfig/#{mac_os_version}" paths << path.to_s if path.exist? end end paths.concat(default_paths) paths.join(SEPARATOR) end