Sha256: 999bb7b3f7babf60b011ae64ac91c95e3aaa41355511090e69839a422439460a

Contents?: true

Size: 811 Bytes

Versions: 6

Compression:

Stored size: 811 Bytes

Contents

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)
compat_functions = %w(PQescapeString PQexecParams)

if have_build_env
  required_libraries.each(&method(:have_library))
  desired_functions.each(&method(:have_func))
  $CFLAGS << ' -Wall '
  dir_config("postgres_c")
  create_makefile("postgres_c")
else
  puts 'Could not find PostgreSQL build environment (libraries & headers): Makefile not created'
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
datamapper-0.2.0 plugins/dataobjects/swig_postgres/extconf.rb
datamapper-0.2.1 plugins/dataobjects/swig_postgres/extconf.rb
datamapper-0.2.2 plugins/dataobjects/swig_postgres/extconf.rb
datamapper-0.2.3 plugins/dataobjects/swig_postgres/extconf.rb
do_postgres-0.2.0 ext/extconf.rb
do_postgres-0.2.1 ext/extconf.rb