summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/ext/dbm/extconf.rb
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 04:06:12 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 04:06:12 +0000
commit11dbedfaad4a9a9521ece2198a8dc491678b1902 (patch)
tree4806dc0ff0c3827ecc40921838c4507340cfdb3a /ruby_1_8_6/ext/dbm/extconf.rb
parent29e8d8b439b34c2a394407dc598fc01d14be0c20 (diff)
add tag v1_8_6_5001v1_8_6_5001
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_5001@13304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/ext/dbm/extconf.rb')
-rw-r--r--ruby_1_8_6/ext/dbm/extconf.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/ruby_1_8_6/ext/dbm/extconf.rb b/ruby_1_8_6/ext/dbm/extconf.rb
new file mode 100644
index 0000000000..0074ab605b
--- /dev/null
+++ b/ruby_1_8_6/ext/dbm/extconf.rb
@@ -0,0 +1,53 @@
+require 'mkmf'
+
+dir_config("dbm")
+
+if dblib = with_config("dbm-type", nil)
+ dblib = dblib.split(/[ ,]+/)
+else
+ dblib = %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
+end
+
+headers = {
+ "db" => ["db.h"],
+ "db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"],
+ "db2" => ["db2/db.h", "db2.h", "db.h"],
+ "dbm" => ["ndbm.h"],
+ "gdbm" => ["gdbm-ndbm.h", "ndbm.h"],
+ "gdbm_compat" => ["gdbm-ndbm.h", "ndbm.h"],
+ "qdbm" => ["relic.h"],
+}
+
+def headers.db_check(db)
+ db_prefix = nil
+ have_gdbm = false
+ hsearch = nil
+
+ case db
+ when /^db2?$/
+ db_prefix = "__db_n"
+ hsearch = "-DDB_DBM_HSEARCH "
+ when "gdbm"
+ have_gdbm = true
+ when "gdbm_compat"
+ have_gdbm = true
+ have_library("gdbm") or return false
+ end
+ db_prefix ||= ""
+
+ if (have_library(db, db_prefix+"dbm_open") || have_func(db_prefix+"dbm_open")) and
+ hdr = self.fetch(db, ["ndbm.h"]).find {|hdr| have_type("DBM", hdr, hsearch)}
+ have_func(db_prefix+"dbm_clearerr") unless have_gdbm
+ $defs << hsearch if hsearch
+ $defs << '-DDBM_HDR="<'+hdr+'>"'
+ true
+ else
+ false
+ end
+end
+
+if dblib.any? {|db| headers.db_check(db)}
+ have_header("cdefs.h")
+ have_header("sys/cdefs.h")
+ create_makefile("dbm")
+end