Merge pull request #2 from ashmoran/bdb_5_and_homebrew_support

BDB 5 and Homebrew support
This commit is contained in:
Denis Knauf 2011-08-07 03:44:21 -07:00
commit ee355fe03b
2 changed files with 10 additions and 7 deletions

View file

@ -827,7 +827,7 @@ VALUE db_join(VALUE obj, VALUE vacurs, VALUE vflags)
return jcurs; return jcurs;
} }
#if DB_VERSION_MINOR > 3 #if DB_VERSION_MAJOR == 5 || DB_VERSION_MINOR > 3
/* /*
* call-seq: * call-seq:
* db.compact(txn,start_key,stop_key,compact_opts,flags) -> end_key * 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); rv=dbh->db->get_type(dbh->db,&dbtype);
if (rv) if (rv)
raise_error(rv,"db_stat %s",db_strerror(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); rv=dbh->db->stat(dbh->db,txn?txn->txn:NULL,&(su.stat),flags);
#else #else
rv=dbh->db->stat(dbh->db,&(su.stat),flags); 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_nkeys); /* Number of unique keys. */
bs_int(bt_ndata); /* Number of data items. */ bs_int(bt_ndata); /* Number of data items. */
bs_int(bt_pagesize); /* Page size. */ 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. */ bs_int(bt_maxkey); /* Maxkey value. */
#endif #endif
bs_int(bt_minkey); /* Minkey value. */ 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_leaf_pg); /* Leaf pages. */
bs_int(bt_dup_pg); /* Duplicate pages. */ bs_int(bt_dup_pg); /* Duplicate pages. */
bs_int(bt_over_pg); /* Overflow 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. */ bs_int(bt_empty_pg); /* Empty pages. */
#endif #endif
bs_int(bt_free); /* Pages on the free list. */ 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,"sync",db_sync,0);
rb_define_method(cDb,"truncate",db_truncate,1); 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); rb_define_method(cDb,"compact",db_compact,5);
#endif #endif

View file

@ -1,13 +1,15 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'mkmf' 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[pdir].each do |dir|
dir_config('db', "#{dir}/include", "#{dir}/lib") dir_config('db', "#{dir}/include", "#{dir}/lib")
end end
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' have_library ver, 'db_version', 'db.h'
end end
@ -18,6 +20,7 @@ def create_header
end end
message("Writing bdb_aux._c (defines), this takes a while\n") message("Writing bdb_aux._c (defines), this takes a while\n")
db_header = $CPPFLAGS.split.select { |f| f =~ /^-I/ }.map { |e| db_header = $CPPFLAGS.split.select { |f| f =~ /^-I/ }.map { |e|
f = File.join(e[2..-1], 'db.h') f = File.join(e[2..-1], 'db.h')
File.exists?(f) ? f : nil File.exists?(f) ? f : nil