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