class PackageConfig
def compute_default_path
def compute_default_path default_paths = nil if native_pkg_config pc_path = run_command(native_pkg_config.to_s, "--variable=pc_path", "pkg-config") if pc_path default_paths = pc_path.strip.split(SEPARATOR) default_paths = nil if default_paths.empty? end end if default_paths.nil? arch_depended_path = Dir.glob("/usr/lib/*/pkgconfig") default_paths = [] pkg_config_prefix = native_pkg_config_prefix if pkg_config_prefix pkg_config_arch_depended_paths = Dir.glob((pkg_config_prefix + "lib/*/pkgconfig").to_s) default_paths.concat(pkg_config_arch_depended_paths) default_paths << (pkg_config_prefix + "lib64/pkgconfig").to_s default_paths << (pkg_config_prefix + "libx32/pkgconfig").to_s default_paths << (pkg_config_prefix + "lib/pkgconfig").to_s default_paths << (pkg_config_prefix + "libdata/pkgconfig").to_s default_paths << (pkg_config_prefix + "share/pkgconfig").to_s end conda_prefix = ENV["CONDA_PREFIX"] if conda_prefix default_paths << File.join(conda_prefix, "lib", "pkgconfig") default_paths << File.join(conda_prefix, "share", "pkgconfig") end default_paths << "/usr/local/lib64/pkgconfig" default_paths << "/usr/local/libx32/pkgconfig" default_paths << "/usr/local/lib/pkgconfig" default_paths << "/usr/local/libdata/pkgconfig" default_paths << "/usr/local/share/pkgconfig" default_paths << "/opt/local/lib/pkgconfig" default_paths.concat(arch_depended_path) default_paths << "/usr/lib64/pkgconfig" default_paths << "/usr/libx32/pkgconfig" default_paths << "/usr/lib/pkgconfig" default_paths << "/usr/libdata/pkgconfig" default_paths << "/usr/X11R6/lib/pkgconfig" default_paths << "/usr/X11R6/share/pkgconfig" default_paths << "/usr/X11/lib/pkgconfig" default_paths << "/opt/X11/lib/pkgconfig" default_paths << "/usr/share/pkgconfig" end 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 = [] if /-darwin\d[\d\.]*\z/ =~ RUBY_PLATFORM and /\A(\d+\.\d+)/ =~ run_command("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? homebrew_repository = run_command(brew_path.to_s, "--repository") if homebrew_repository homebrew_repository_candidates << Pathname.new(homebrew_repository.strip) end else homebrew_repository_candidates << pkg_config_prefix + "Homebrew" homebrew_repository_candidates << pkg_config_prefix end end brew = search_executable_from_path("brew") if brew homebrew_repository = run_command("brew", "--repository") if homebrew_repository homebrew_repository_candidates << Pathname(homebrew_repository.to_s) end end homebrew_repository_candidates.uniq.each do |candidate| pkgconfig_base_path = candidate + "Library/Homebrew/os/mac/pkgconfig" path = pkgconfig_base_path + mac_os_version unless path.exist? path = pkgconfig_base_path + mac_os_version.gsub(/\.\d+\z/, "") end paths << path.to_s if path.exist? end end paths.concat(default_paths) paths.join(SEPARATOR) end