summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-13 14:55:30 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-13 14:55:30 +0000
commitf360ad8106ea9a485d47543622edeb1288ac70ef (patch)
tree7372a17ffe00e892d05f008e8013265e10256bb8
parente71c9d1c4a6806a33fa89f49e0090f0f63e71a2c (diff)
* ext/dbm/extconf.rb: backported from 1.7.
* ext/dbm/dbm.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@3142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--ext/dbm/dbm.c2
-rw-r--r--ext/dbm/extconf.rb54
3 files changed, 56 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index e3101669e9..f5900136fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Dec 13 23:39:09 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/dbm/extconf.rb: backported from 1.7.
+
+ * ext/dbm/dbm.c: ditto.
+
Thu Dec 12 16:26:31 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* marshal.c (r_object0): singleton class instance can't be loaded.
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 94b07712c3..8edce9b9d0 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -18,7 +18,7 @@
#ifdef HAVE_SYS_CDEFS_H
# include <sys/cdefs.h>
#endif
-#include <ndbm.h>
+#include DBM_HDR
#include <fcntl.h>
#include <errno.h>
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 9ce235a2b5..5c1afe7d34 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -1,13 +1,57 @@
require 'mkmf'
dir_config("dbm")
-if have_library("gdbm", "dbm_open")
- gdbm = true
+
+dblib = with_config("dbm-type", nil)
+
+$dbm_conf_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"],
+}
+
+def db_check(db)
+ $dbm_conf_db_prefix = ""
+ $dbm_conf_have_gdbm = false
+ hsearch = ""
+
+ case db
+ when /^db2?$/
+ $dbm_conf_db_prefix = "__db_n"
+ hsearch = "-DDB_DBM_HSEARCH "
+ when "gdbm"
+ $dbm_conf_have_gdbm = true
+ end
+
+ if have_library(db, db_prefix("dbm_open")) || have_func(db_prefix("dbm_open"))
+ for hdr in $dbm_conf_headers.fetch(db, ["ndbm.h"])
+ if have_header(hdr.dup)
+ $CFLAGS += " " + hsearch + "-DDBM_HDR='<"+hdr+">'"
+ return true
+ end
+ end
+ end
+ return false
end
-gdbm or have_library("db", "dbm_open") or have_library("dbm", "dbm_open")
+
+def db_prefix(func)
+ $dbm_conf_db_prefix+func
+end
+
+if dblib
+ db_check(dblib)
+else
+ for dblib in %w(db db2 db1 dbm gdbm)
+ db_check(dblib) and break
+ end
+end
+
have_header("cdefs.h")
have_header("sys/cdefs.h")
-if have_header("ndbm.h") and have_func("dbm_open")
- have_func("dbm_clearerr") unless gdbm
+if /DBM_HDR/ =~ $CFLAGS and have_func(db_prefix("dbm_open"))
+ have_func(db_prefix("dbm_clearerr")) unless $dbm_conf_have_gdbm
create_makefile("dbm")
end