diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-24 15:51:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-24 15:51:03 +0000 |
commit | 18cf07cc7cc9af85a5e6d0e35bc3c306c93729be (patch) | |
tree | ff87cca167556ad6d07742858327926f9ec1a18d | |
parent | 865efd821e9db20419bd869d2574500fc90aeb2d (diff) | |
download | ruby-18cf07cc7cc9af85a5e6d0e35bc3c306c93729be.tar.gz |
* lib/mkmf.rb (pkg_config): particular config commands support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/mkmf.rb | 30 |
2 files changed, 24 insertions, 10 deletions
@@ -1,3 +1,7 @@ +Thu May 25 00:51:18 2006 nobuyoshi nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (pkg_config): particular config commands support. + Wed May 24 23:52:11 2006 nobuyoshi nakada <nobu@ruby-lang.org> * configure.in (ac_install_sh): ignore dummy install-sh. diff --git a/lib/mkmf.rb b/lib/mkmf.rb index f9a4d237b3..5c3a0266ce 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -880,16 +880,23 @@ def dir_config(target, idefault=nil, ldefault=nil) end def pkg_config(pkg) - unless defined?($PKGCONFIG) - if pkgconfig = with_config("pkg-config", !CROSS_COMPILING && "pkg-config") - find_executable0(pkgconfig) or pkgconfig = nil - end - $PKGCONFIG = pkgconfig - end - if $PKGCONFIG and system("#{$PKGCONFIG} --exists #{pkg}") - cflags = `#{$PKGCONFIG} --cflags #{pkg}`.chomp - ldflags = `#{$PKGCONFIG} --libs #{pkg}`.chomp - libs = `#{$PKGCONFIG} --libs-only-l #{pkg}`.chomp + if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig) + # iff package specific config command is given + 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}") + # default to pkg-config command + get = proc {|opt| `#{$PKGCONFIG} --#{opt} #{pkg}`.chomp} + elsif find_executable0(pkgconfig = "#{pkg}-config") + # default to package specific config command, as a last resort. + 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 @@ -898,6 +905,9 @@ def pkg_config(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 |