@@ -72,18 +72,25 @@ def with_config(config, default=nil)
7272
7373 def guess_native_pkg_config
7474 exeext = RbConfig ::CONFIG [ "EXEEXT" ]
75- default_pkg_config = ENV [ "PKG_CONFIG" ] || "pkg-config#{ exeext } "
76- pkg_config = with_config ( "pkg-config" , default_pkg_config )
77- pkg_config = Pathname . new ( pkg_config )
78- unless pkg_config . absolute?
79- found_pkg_config = search_executable_from_path ( pkg_config )
80- pkg_config = found_pkg_config if found_pkg_config
81- end
82- unless pkg_config . absolute?
83- found_pkg_config = search_pkg_config_by_dln_find_exe ( pkg_config )
84- pkg_config = found_pkg_config if found_pkg_config
75+ candidates = [
76+ with_config ( "pkg-config" ) ,
77+ ENV [ "PKG_CONFIG" ] ,
78+ "pkgconf#{ exeext } " ,
79+ "pkg-config#{ exeext } " ,
80+ ] . compact
81+ candidates . each do |pkg_config |
82+ pkg_config = Pathname . new ( pkg_config )
83+ return pkg_config if pkg_config . absolute? and pkg_config . exist?
84+ unless pkg_config . absolute?
85+ found_pkg_config = search_executable_from_path ( pkg_config )
86+ return found_pkg_config if found_pkg_config
87+ end
88+ unless pkg_config . absolute?
89+ found_pkg_config = search_pkg_config_by_dln_find_exe ( pkg_config )
90+ return found_pkg_config if found_pkg_config
91+ end
8592 end
86- pkg_config
93+ Pathname . new ( candidates [ 0 ] )
8794 end
8895
8996 def search_executable_from_path ( name )
0 commit comments