Sha256: 62b5de04fd5d80a48ae15c484664a3ac983a1c23a1443003154ce71cb9af27fe

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

if RUBY_VERSION < '1.3'
  puts 'This library is for ruby-1.3 or higher.'
  exit 1
end

require 'mkmf'

def config_value(type)
  ENV["POSTGRES_#{type.upcase}"] || pg_config(type)
end

def pg_config(type)
  IO.popen("pg_config --#{type}dir").readline.chomp rescue nil
end

def have_build_env
  have_library('pq') && have_header('libpq-fe.h') && have_header('libpq/libpq-fs.h')
end

dir_config('pgsql', config_value('include'), config_value('lib'))

required_libraries = []
desired_functions = %w(PQsetClientEncoding pg_encoding_to_char PQfreemem PQserverVersion)
compat_functions = %w(PQescapeString PQexecParams)

if have_build_env
  required_libraries.each(&method(:have_library))
  desired_functions.each(&method(:have_func))
  $objs = ['postgres.o','libpq-compat.o'] if compat_functions.all?(&method(:have_func))
  $CFLAGS << ' -Wall '
  create_makefile("postgres")
else
  puts 'Could not find PostgreSQL build environment (libraries & headers): Makefile not created'
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
postgres-0.7.9.2007.12.22 compat-ruby-postgres/extconf.rb
postgres-0.7.9.2008.01.09 ext/extconf.rb
postgres-0.7.9.2008.01.03 compat-ruby-postgres/extconf.rb