File use-pkg-config.patch of Package rubygem-pg
Index: pg-1.1.4/ext/extconf.rb
===================================================================
--- pg-1.1.4.orig/ext/extconf.rb
+++ pg-1.1.4/ext/extconf.rb
@@ -23,27 +23,29 @@ if enable_config("windows-cross")
else
# Native build
+ pg_package = pkg_config('libpq')
+ if !pg_package
+ pgconfig = with_config('pg-config') ||
+ with_config('pg_config') ||
+ find_executable('pg_config')
- pgconfig = with_config('pg-config') ||
- with_config('pg_config') ||
- find_executable('pg_config')
+ if pgconfig && pgconfig != 'ignore'
+ $stderr.puts "Using config values from %s" % [ pgconfig ]
+ incdir = `"#{pgconfig}" --includedir`.chomp
+ libdir = `"#{pgconfig}" --libdir`.chomp
+ dir_config 'pg', incdir, libdir
- if pgconfig && pgconfig != 'ignore'
- $stderr.puts "Using config values from %s" % [ pgconfig ]
- incdir = `"#{pgconfig}" --includedir`.chomp
- libdir = `"#{pgconfig}" --libdir`.chomp
- dir_config 'pg', incdir, libdir
-
- # Try to use runtime path linker option, even if RbConfig doesn't know about it.
- # The rpath option is usually set implicit by dir_config(), but so far not
- # on MacOS-X.
- if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', " -Wl,-rpath,#{libdir}")
- $LDFLAGS << " -Wl,-rpath,#{libdir}"
+ # Try to use runtime path linker option, even if RbConfig doesn't know about it.
+ # The rpath option is usually set implicit by dir_config(), but so far not
+ # on MacOS-X.
+ if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', " -Wl,-rpath,#{libdir}")
+ $LDFLAGS << " -Wl,-rpath,#{libdir}"
+ end
+ else
+ $stderr.puts "No pg_config... trying anyway. If building fails, please try again with",
+ " --with-pg-config=/path/to/pg_config"
+ dir_config 'pg'
end
- else
- $stderr.puts "No pg_config... trying anyway. If building fails, please try again with",
- " --with-pg-config=/path/to/pg_config"
- dir_config 'pg'
end
end