From 236b5acfba228bbfba8fce6b9a85cc97eb2c7040 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 23 Nov 2022 16:18:47 +0900 Subject: [PATCH] Don't use parent directory of pkg-config for default path If "pkg-config --variable=pc_path pkg-config" works. GitHub: fix GH-22 Reported by Watson. Thanks!!! --- lib/pkg-config.rb | 57 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/lib/pkg-config.rb b/lib/pkg-config.rb index 9c226fb..9af0d63 100644 --- a/lib/pkg-config.rb +++ b/lib/pkg-config.rb @@ -158,24 +158,34 @@ def compute_default_path end if default_paths.nil? 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", - ] + 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 + 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 @@ -186,17 +196,6 @@ def compute_default_path default_paths.unshift(libdir) if libdir 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) - 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 - paths << (pkg_config_prefix + "share/pkgconfig").to_s - end if /-darwin\d[\d\.]*\z/ =~ RUBY_PLATFORM and /\A(\d+\.\d+)/ =~ run_command("sw_vers", "-productVersion") mac_os_version = $1