diff options
Diffstat (limited to 'lib/mkmf.rb')
-rw-r--r-- | lib/mkmf.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb index c2690969b4..2a83189e30 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1759,22 +1759,37 @@ SRC def pkg_config(pkg, option=nil) if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig) # iff package specific config command is given - get = proc {|opt| `#{pkgconfig} --#{opt}`.strip} elsif ($PKGCONFIG ||= (pkgconfig = with_config("pkg-config", ("pkg-config" unless CROSS_COMPILING))) && find_executable0(pkgconfig) && pkgconfig) and system("#{$PKGCONFIG} --exists #{pkg}") # default to pkg-config command - get = proc {|opt| `#{$PKGCONFIG} --#{opt} #{pkg}`.strip} + pkgconfig = $PKGCONFIG + get = proc {|opt| + opt = IO.popen("#{$PKGCONFIG} --#{opt} #{pkg}", err:[:child, :out], &:read) + opt.strip if $?.success? + } elsif find_executable0(pkgconfig = "#{pkg}-config") # default to package specific config command, as a last resort. - get = proc {|opt| `#{pkgconfig} --#{opt}`.strip} + else + pkgconfig = nil + end + if pkgconfig + get ||= proc {|opt| + opt = IO.popen("#{pkgconfig} --#{opt}", err:[:child, :out], &:read) + opt.strip if $?.success? + } end orig_ldflags = $LDFLAGS if get and option get[option] elsif get and try_ldflags(ldflags = get['libs']) - cflags = get['cflags'] + if incflags = get['cflags-only-I'] + $INCFLAGS << " " << incflags + cflags = get['cflags-only-other'] + else + cflags = get['cflags'] + end libs = get['libs-only-l'] ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ") $CFLAGS += " " << cflags |