summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-16 07:14:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-16 07:14:37 +0000
commit5e6bf721d59f372a66207c38d9b3f5f7a2e3f468 (patch)
treea034372aec7a9b511c384c7b95a024469f9caecb
parentf06362a4f9aab177009dbedb0242fd90811cfca2 (diff)
* ext/dbm/extconf.rb: allow multiple candidates for dbm-type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/dbm/extconf.rb60
2 files changed, 29 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index fb8a394185..bfe1da6efc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,12 @@
-Mon Jan 16 16:06:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Sep 16 16:13:50 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in, common.in, instruby.rb, ext/extmk.rb, lib/mkmf.rb:
use instruby.rb to install extensions instead of ext/extmk.rb.
* instruby.rb: store installed list into the file.
+ * ext/dbm/extconf.rb: allow multiple candidates for dbm-type.
+
Sat Sep 16 11:03:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (ary_shared_first): should create embedded copies
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 52ec688952..0074ab605b 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -2,9 +2,13 @@ require 'mkmf'
dir_config("dbm")
-dblib = with_config("dbm-type", nil)
+if dblib = with_config("dbm-type", nil)
+ dblib = dblib.split(/[ ,]+/)
+else
+ dblib = %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
+end
-$dbm_conf_headers = {
+headers = {
"db" => ["db.h"],
"db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"],
"db2" => ["db2/db.h", "db2.h", "db.h"],
@@ -14,48 +18,36 @@ $dbm_conf_headers = {
"qdbm" => ["relic.h"],
}
-def db_check(db)
- $dbm_conf_db_prefix = ""
- $dbm_conf_have_gdbm = false
- hsearch = ""
+def headers.db_check(db)
+ db_prefix = nil
+ have_gdbm = false
+ hsearch = nil
case db
when /^db2?$/
- $dbm_conf_db_prefix = "__db_n"
+ db_prefix = "__db_n"
hsearch = "-DDB_DBM_HSEARCH "
when "gdbm"
- $dbm_conf_have_gdbm = true
+ have_gdbm = true
when "gdbm_compat"
- $dbm_conf_have_gdbm = true
+ have_gdbm = true
have_library("gdbm") or return false
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) and have_type("DBM", hdr.dup, hsearch)
- $defs << hsearch << '-DDBM_HDR="<'+hdr+'>"'
- return true
- end
- end
- end
- return false
-end
-
-def db_prefix(func)
- $dbm_conf_db_prefix+func
-end
-
-if dblib
- dbm_hdr = db_check(dblib)
-else
- dbm_hdr = %w(db db2 db1 dbm gdbm gdbm_compat qdbm).any? do |dblib|
- db_check(dblib)
+ 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
-have_header("cdefs.h")
-have_header("sys/cdefs.h")
-if dbm_hdr and have_func(db_prefix("dbm_open"))
- have_func(db_prefix("dbm_clearerr")) unless $dbm_conf_have_gdbm
+if dblib.any? {|db| headers.db_check(db)}
+ have_header("cdefs.h")
+ have_header("sys/cdefs.h")
create_makefile("dbm")
end