1999-01-20 07:59:39 +03:00
|
|
|
require 'mkmf'
|
1999-08-24 12:21:56 +04:00
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
dir_config("dbm")
|
2001-05-02 08:22:21 +04:00
|
|
|
|
|
|
|
dblib = with_config("dbm-type", nil)
|
|
|
|
|
2001-05-24 09:28:15 +04:00
|
|
|
$dbm_conf_headers = {
|
|
|
|
"db" => ["db.h"],
|
2001-05-24 19:55:40 +04:00
|
|
|
"db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"],
|
2001-05-24 09:28:15 +04:00
|
|
|
"db2" => ["db2/db.h", "db2.h", "db.h"],
|
|
|
|
"dbm" => ["ndbm.h"],
|
2001-06-01 06:25:28 +04:00
|
|
|
"gdbm" => ["gdbm-ndbm.h", "ndbm.h"],
|
2002-12-13 20:14:18 +03:00
|
|
|
"gdbm_compat" => ["gdbm-ndbm.h", "ndbm.h"],
|
2003-03-07 09:06:58 +03:00
|
|
|
"qdbm" => ["relic.h"],
|
2001-05-24 09:28:15 +04:00
|
|
|
}
|
|
|
|
|
2001-05-02 08:22:21 +04:00
|
|
|
def db_check(db)
|
2001-05-24 09:28:15 +04:00
|
|
|
$dbm_conf_db_prefix = ""
|
|
|
|
$dbm_conf_have_gdbm = false
|
|
|
|
hsearch = ""
|
2001-05-07 14:56:01 +04:00
|
|
|
|
|
|
|
case db
|
|
|
|
when /^db2?$/
|
2001-05-24 09:28:15 +04:00
|
|
|
$dbm_conf_db_prefix = "__db_n"
|
|
|
|
hsearch = "-DDB_DBM_HSEARCH "
|
2001-05-07 14:56:01 +04:00
|
|
|
when "gdbm"
|
2001-05-24 09:28:15 +04:00
|
|
|
$dbm_conf_have_gdbm = true
|
2002-12-13 20:14:18 +03:00
|
|
|
when "gdbm_compat"
|
|
|
|
$dbm_conf_have_gdbm = true
|
|
|
|
have_library("gdbm") or return false
|
2001-05-02 08:22:21 +04:00
|
|
|
end
|
2001-05-07 14:56:01 +04:00
|
|
|
|
2002-12-13 17:54:24 +03:00
|
|
|
if have_library(db, db_prefix("dbm_open")) || have_func(db_prefix("dbm_open"))
|
2001-05-24 09:28:15 +04:00
|
|
|
for hdr in $dbm_conf_headers.fetch(db, ["ndbm.h"])
|
2003-07-24 11:41:36 +04:00
|
|
|
if have_header(hdr.dup) and have_type("DBM", hdr.dup, hsearch)
|
2006-05-26 03:44:08 +04:00
|
|
|
$defs << hsearch << '-DDBM_HDR="<'+hdr+'>"'
|
2001-05-24 19:55:40 +04:00
|
|
|
return true
|
2001-05-24 09:28:15 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
2001-05-02 08:22:21 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def db_prefix(func)
|
2001-05-24 09:28:15 +04:00
|
|
|
$dbm_conf_db_prefix+func
|
1999-08-24 12:21:56 +04:00
|
|
|
end
|
2001-05-02 08:22:21 +04:00
|
|
|
|
|
|
|
if dblib
|
2006-09-04 16:44:33 +04:00
|
|
|
dbm_hdr = db_check(dblib)
|
2001-05-02 08:22:21 +04:00
|
|
|
else
|
2006-09-04 16:44:33 +04:00
|
|
|
dbm_hdr = %w(db db2 db1 dbm gdbm gdbm_compat qdbm).any? do |dblib|
|
|
|
|
db_check(dblib)
|
2001-05-02 08:22:21 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
have_header("cdefs.h")
|
2000-09-12 09:37:38 +04:00
|
|
|
have_header("sys/cdefs.h")
|
2006-09-04 16:44:33 +04:00
|
|
|
if dbm_hdr and have_func(db_prefix("dbm_open"))
|
2001-05-24 09:28:15 +04:00
|
|
|
have_func(db_prefix("dbm_clearerr")) unless $dbm_conf_have_gdbm
|
1998-01-16 15:13:05 +03:00
|
|
|
create_makefile("dbm")
|
|
|
|
end
|