def pkg_config(pkg)
if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
get = proc {|opt| `#{pkgconfig} --#{opt}`.chomp}
elsif ($PKGCONFIG ||=
(pkgconfig = with_config("pkg-config", ("pkg-config" unless CROSS_COMPILING))) &&
find_executable0(pkgconfig) && pkgconfig) and
system("#{$PKGCONFIG} --exists #{pkg}")
get = proc {|opt| `#{$PKGCONFIG} --#{opt} #{pkg}`.chomp}
elsif find_executable0(pkgconfig = "#{pkg}-config")
get = proc {|opt| `#{pkgconfig} --#{opt}`.chomp}
end
if get
cflags = get['cflags']
ldflags = get['libs']
libs = get['libs-only-l']
ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ")
$CFLAGS += " " << cflags
$LDFLAGS += " " << ldflags
$libs += " " << libs
Logging::message "package configuration for %s\n", pkg
Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n",
cflags, ldflags, libs
[cflags, ldflags, libs]
else
Logging::message "package configuration for %s is not found\n", pkg
nil
end
end