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
|
|
|
|
2006-09-16 11:14:37 +04:00
|
|
|
if dblib = with_config("dbm-type", nil)
|
|
|
|
dblib = dblib.split(/[ ,]+/)
|
|
|
|
else
|
2010-06-11 19:40:39 +04:00
|
|
|
dblib = %w(db db2 db1 db5 db4 db3 dbm gdbm gdbm_compat qdbm)
|
2006-09-16 11:14:37 +04:00
|
|
|
end
|
2001-05-02 08:22:21 +04:00
|
|
|
|
2006-09-16 11:14:37 +04:00
|
|
|
headers = {
|
2001-05-24 09:28:15 +04:00
|
|
|
"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"],
|
2010-06-11 19:40:39 +04:00
|
|
|
"db3" => ["db3/db.h", "db3.h", "db.h"],
|
|
|
|
"db4" => ["db4/db.h", "db4.h", "db.h"],
|
|
|
|
"db5" => ["db5/db.h", "db5.h", "db.h"],
|
2001-05-24 09:28:15 +04:00
|
|
|
"dbm" => ["ndbm.h"],
|
2011-01-28 15:58:15 +03:00
|
|
|
"gdbm" => ["gdbm-ndbm.h", "ndbm.h", "gdbm/ndbm.h"],
|
|
|
|
"gdbm_compat" => ["gdbm-ndbm.h", "ndbm.h", "gdbm/ndbm.h"],
|
|
|
|
"qdbm" => ["relic.h", "qdbm/relic.h"],
|
2001-05-24 09:28:15 +04:00
|
|
|
}
|
|
|
|
|
2011-11-08 18:34:39 +04:00
|
|
|
class << headers
|
|
|
|
attr_accessor :found
|
|
|
|
end
|
|
|
|
headers.found = []
|
2011-11-07 15:17:17 +04:00
|
|
|
|
2006-09-16 11:14:37 +04:00
|
|
|
def headers.db_check(db)
|
|
|
|
db_prefix = nil
|
|
|
|
have_gdbm = false
|
|
|
|
hsearch = nil
|
2001-05-07 14:56:01 +04:00
|
|
|
|
|
|
|
case db
|
2010-06-11 19:40:39 +04:00
|
|
|
when /^db[2-5]?$/
|
2006-09-16 11:14:37 +04:00
|
|
|
db_prefix = "__db_n"
|
2001-05-24 09:28:15 +04:00
|
|
|
hsearch = "-DDB_DBM_HSEARCH "
|
2001-05-07 14:56:01 +04:00
|
|
|
when "gdbm"
|
2006-09-16 11:14:37 +04:00
|
|
|
have_gdbm = true
|
2002-12-13 20:14:18 +03:00
|
|
|
when "gdbm_compat"
|
2006-09-16 11:14:37 +04:00
|
|
|
have_gdbm = true
|
2002-12-13 20:14:18 +03:00
|
|
|
have_library("gdbm") or return false
|
2001-05-02 08:22:21 +04:00
|
|
|
end
|
2006-09-16 11:14:37 +04:00
|
|
|
db_prefix ||= ""
|
|
|
|
|
|
|
|
if (have_library(db, db_prefix+"dbm_open") || have_func(db_prefix+"dbm_open")) and
|
2010-06-11 19:40:39 +04:00
|
|
|
hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h, hsearch)} or
|
|
|
|
hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", ["db.h", h], hsearch)}
|
2006-09-16 11:14:37 +04:00
|
|
|
have_func(db_prefix+"dbm_clearerr") unless have_gdbm
|
|
|
|
$defs << hsearch if hsearch
|
|
|
|
$defs << '-DDBM_HDR="<'+hdr+'>"'
|
2011-11-08 18:34:39 +04:00
|
|
|
@found << hdr
|
2006-09-16 11:14:37 +04:00
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
2001-05-02 08:22:21 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-09-16 11:14:37 +04:00
|
|
|
if dblib.any? {|db| headers.db_check(db)}
|
|
|
|
have_header("cdefs.h")
|
|
|
|
have_header("sys/cdefs.h")
|
2011-11-08 18:34:39 +04:00
|
|
|
have_func("dbm_pagfno", headers.found)
|
|
|
|
have_func("dbm_dirfno", headers.found)
|
2011-11-10 10:43:44 +04:00
|
|
|
type = checking_for "sizeof(datum.dsize)", STRING_OR_FAILED_FORMAT do
|
|
|
|
pre = headers.found + [["static datum conftest_key;"]]
|
|
|
|
%w[int long LONG_LONG].find do |t|
|
|
|
|
try_static_assert("sizeof(conftest_key.dsize) <= sizeof(#{t})", pre)
|
|
|
|
end
|
2011-11-08 18:34:39 +04:00
|
|
|
end
|
2011-11-10 10:43:44 +04:00
|
|
|
$defs << "-DSIZEOF_DSIZE=SIZEOF_"+type.tr_cpp if type
|
1998-01-16 15:13:05 +03:00
|
|
|
create_makefile("dbm")
|
|
|
|
end
|