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
|
|
|
|
2006-09-16 03:14:37 -04:00
|
|
|
if dblib = with_config("dbm-type", nil)
|
|
|
|
dblib = dblib.split(/[ ,]+/)
|
|
|
|
else
|
|
|
|
dblib = %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
|
|
|
|
end
|
2001-05-02 00:22:21 -04:00
|
|
|
|
2006-09-16 03:14:37 -04:00
|
|
|
headers = {
|
2001-05-24 01:28:15 -04:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
2006-09-16 03:14:37 -04:00
|
|
|
def headers.db_check(db)
|
|
|
|
db_prefix = nil
|
|
|
|
have_gdbm = false
|
|
|
|
hsearch = nil
|
2001-05-07 06:56:01 -04:00
|
|
|
|
|
|
|
case db
|
|
|
|
when /^db2?$/
|
2006-09-16 03:14:37 -04:00
|
|
|
db_prefix = "__db_n"
|
2001-05-24 01:28:15 -04:00
|
|
|
hsearch = "-DDB_DBM_HSEARCH "
|
2001-05-07 06:56:01 -04:00
|
|
|
when "gdbm"
|
2006-09-16 03:14:37 -04:00
|
|
|
have_gdbm = true
|
2002-12-13 12:14:18 -05:00
|
|
|
when "gdbm_compat"
|
2006-09-16 03:14:37 -04:00
|
|
|
have_gdbm = true
|
2002-12-13 12:14:18 -05:00
|
|
|
have_library("gdbm") or return false
|
2001-05-02 00:22:21 -04:00
|
|
|
end
|
2006-09-16 03:14:37 -04:00
|
|
|
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
|
2001-05-02 00:22:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-09-16 03:14:37 -04:00
|
|
|
if dblib.any? {|db| headers.db_check(db)}
|
|
|
|
have_header("cdefs.h")
|
|
|
|
have_header("sys/cdefs.h")
|
1998-01-16 07:13:05 -05:00
|
|
|
create_makefile("dbm")
|
|
|
|
end
|