diff --git a/ext/bdb.c b/ext/bdb.c index 8a70964..fefe1c0 100644 --- a/ext/bdb.c +++ b/ext/bdb.c @@ -827,7 +827,7 @@ VALUE db_join(VALUE obj, VALUE vacurs, VALUE vflags) return jcurs; } -#if DB_VERSION_MINOR > 3 +#if DB_VERSION_MAJOR == 5 || DB_VERSION_MINOR > 3 /* * call-seq: * db.compact(txn,start_key,stop_key,compact_opts,flags) -> end_key @@ -2105,7 +2105,7 @@ VALUE db_stat(VALUE obj, VALUE vtxn, VALUE vflags) rv=dbh->db->get_type(dbh->db,&dbtype); if (rv) raise_error(rv,"db_stat %s",db_strerror(rv)); -#if DB_VERSION_MINOR > 2 +#if DB_VERSION_MAJOR == 5 || DB_VERSION_MINOR > 2 rv=dbh->db->stat(dbh->db,txn?txn->txn:NULL,&(su.stat),flags); #else rv=dbh->db->stat(dbh->db,&(su.stat),flags); @@ -2151,7 +2151,7 @@ VALUE db_stat(VALUE obj, VALUE vtxn, VALUE vflags) bs_int(bt_nkeys); /* Number of unique keys. */ bs_int(bt_ndata); /* Number of data items. */ bs_int(bt_pagesize); /* Page size. */ -#if DB_VERSION_MINOR < 4 +#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 4 bs_int(bt_maxkey); /* Maxkey value. */ #endif bs_int(bt_minkey); /* Minkey value. */ @@ -2162,7 +2162,7 @@ VALUE db_stat(VALUE obj, VALUE vtxn, VALUE vflags) bs_int(bt_leaf_pg); /* Leaf pages. */ bs_int(bt_dup_pg); /* Duplicate pages. */ bs_int(bt_over_pg); /* Overflow pages. */ -#if DB_VERSION_MINOR > 2 +#if DB_VERSION_MAJOR == 5 || DB_VERSION_MINOR > 2 bs_int(bt_empty_pg); /* Empty pages. */ #endif bs_int(bt_free); /* Pages on the free list. */ @@ -3331,7 +3331,7 @@ EXCEPTIONS_CREATE rb_define_method(cDb,"sync",db_sync,0); rb_define_method(cDb,"truncate",db_truncate,1); -#if DB_VERSION_MINOR > 3 +#if DB_VERSION_MAJOR == 5 || DB_VERSION_MINOR > 3 rb_define_method(cDb,"compact",db_compact,5); #endif diff --git a/ext/extconf.rb b/ext/extconf.rb index 1110a04..bf07331 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -1,13 +1,15 @@ #!/usr/bin/env ruby require 'mkmf' -%w[/usr/local /usr / /usr/local/db* /usr/local/BerkeleyDB*].each do |pdir| +# This list is checked in reverse order, so this order allows mkmf on my Mac +# to find BDB installed via Homebrew (/usr/local) before system installs +%w[/usr / /usr/local /usr/local/db* /usr/local/BerkeleyDB*].each do |pdir| Dir[pdir].each do |dir| dir_config('db', "#{dir}/include", "#{dir}/lib") end end -%w(db-4.9 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2).each do |ver| +%w(db-5.1 db-5.0 db-4.9 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2).each do |ver| have_library ver, 'db_version', 'db.h' end @@ -18,6 +20,7 @@ def create_header end message("Writing bdb_aux._c (defines), this takes a while\n") + db_header = $CPPFLAGS.split.select { |f| f =~ /^-I/ }.map { |e| f = File.join(e[2..-1], 'db.h') File.exists?(f) ? f : nil