Sha256: 2b9c554f6c5821b463584f0ce0189fdca30e383947b2000b9e2602941b325e76

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

ENV["RC_ARCHS"] = "" if RUBY_PLATFORM =~ /darwin/

require 'mkmf'

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

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

def have_build_env
  (have_library('pq') || have_library('libpq')) &&
  have_header('libpq-fe.h') && have_header('libpq/libpq-fs.h') &&
  have_header('postgres.h') && have_header('mb/pg_wchar.h') &&
  have_header('catalog/pg_type.h')
end

$CFLAGS << '-UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT' if RUBY_PLATFORM =~ /mswin|mingw/

dir_config('pgsql-server', config_value('includedir-server'), config_value('libdir'))
dir_config('pgsql-client', config_value('includedir'), config_value('libdir'))
dir_config('pgsql-win32') if RUBY_PLATFORM =~ /mswin|mingw/

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 ' unless RUBY_PLATFORM =~ /mswin/
  if RUBY_VERSION < '1.8.6'
    $CFLAGS << ' -DRUBY_LESS_THAN_186'
  end

  create_makefile("do_postgres_ext")
else
  puts 'Could not find PostgreSQL build environment (libraries & headers): Makefile not created'
  exit(1)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
do_postgres-0.10.0-x86-mswin32-60 ext/do_postgres_ext/extconf.rb
do_postgres-0.10.0-x86-mingw32 ext/do_postgres_ext/extconf.rb
do_postgres-0.10.0 ext/do_postgres_ext/extconf.rb