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
|
2011-11-13 02:25:40 -05:00
|
|
|
dblib = %w(libc db db2 db1 db5 db4 db3 dbm gdbm gdbm_compat qdbm)
|
2006-09-16 03:14:37 -04:00
|
|
|
end
|
2001-05-02 00:22:21 -04:00
|
|
|
|
2006-09-16 03:14:37 -04:00
|
|
|
headers = {
|
2011-11-14 06:22:15 -05:00
|
|
|
"libc" => ["ndbm.h"], # 4.4BSD libc contains Berkeley DB 1.
|
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"],
|
2010-06-11 11: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"],
|
2011-11-14 06:22:15 -05:00
|
|
|
"dbm" => ["ndbm.h"], # traditional ndbm (4.3BSD)
|
2011-11-12 02:50:12 -05:00
|
|
|
"gdbm" => ["gdbm-ndbm.h", "ndbm.h", "gdbm/ndbm.h"], # gdbm until 1.8.0
|
|
|
|
"gdbm_compat" => ["gdbm-ndbm.h", "ndbm.h", "gdbm/ndbm.h"], # gdbm since 1.8.1
|
2011-01-28 07:58:15 -05:00
|
|
|
"qdbm" => ["relic.h", "qdbm/relic.h"],
|
2001-05-24 01:28:15 -04:00
|
|
|
}
|
|
|
|
|
2011-11-08 09:34:39 -05:00
|
|
|
class << headers
|
|
|
|
attr_accessor :found
|
2011-11-10 01:43:46 -05:00
|
|
|
attr_accessor :defs
|
2011-11-08 09:34:39 -05:00
|
|
|
end
|
|
|
|
headers.found = []
|
2011-11-10 01:43:46 -05:00
|
|
|
headers.defs = nil
|
2011-11-07 06:17:17 -05:00
|
|
|
|
2011-11-13 05:58:18 -05:00
|
|
|
def headers.db_check(db, hdr)
|
2011-11-13 01:41:19 -05:00
|
|
|
old_libs = $libs.dup
|
|
|
|
old_defs = $defs.dup
|
2011-11-13 05:58:18 -05:00
|
|
|
result = db_check2(db, hdr)
|
2011-11-12 22:47:07 -05:00
|
|
|
if !result
|
|
|
|
$libs = old_libs
|
|
|
|
$defs = old_defs
|
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2011-12-05 22:38:07 -05:00
|
|
|
def have_libvar(var, headers = nil, opt = "", &b)
|
|
|
|
checking_for checking_message([*var].compact.join(' '), headers, opt) do
|
|
|
|
try_libvar(var, headers, opt, &b)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def try_libvar(var, headers = nil, opt = "", &b)
|
|
|
|
var, type = *var
|
|
|
|
if try_link(<<"SRC", opt, &b)
|
|
|
|
#{cpp_include(headers)}
|
|
|
|
/*top*/
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
typedef #{type || 'int'} conftest_type;
|
|
|
|
extern conftest_type #{var};
|
|
|
|
conftest_type *conftest_var = &#{var};
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
SRC
|
|
|
|
$defs.push(format("-DHAVE_LIBVAR_%s", var.tr_cpp))
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-11-13 05:58:18 -05:00
|
|
|
def headers.db_check2(db, hdr)
|
2006-09-16 03:14:37 -04:00
|
|
|
hsearch = nil
|
2001-05-07 06:56:01 -04:00
|
|
|
|
|
|
|
case db
|
2010-06-11 11:40:39 -04:00
|
|
|
when /^db[2-5]?$/
|
2011-11-10 01:43:46 -05:00
|
|
|
hsearch = "-DDB_DBM_HSEARCH"
|
2002-12-13 12:14:18 -05:00
|
|
|
when "gdbm_compat"
|
|
|
|
have_library("gdbm") or return false
|
2001-05-02 00:22:21 -04:00
|
|
|
end
|
2006-09-16 03:14:37 -04:00
|
|
|
|
2011-11-17 06:45:32 -05:00
|
|
|
if have_type("DBM", hdr, hsearch) and
|
2011-11-13 02:25:40 -05:00
|
|
|
(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
|
|
|
|
have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch)) and
|
2011-11-12 02:06:09 -05:00
|
|
|
have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
|
2011-12-06 05:21:12 -05:00
|
|
|
case db
|
|
|
|
when /\Adb\d?\z/
|
|
|
|
have_func('db_version((int *)0, (int *)0, (int *)0)', hdr, hsearch)
|
|
|
|
when /\Agdbm/
|
2011-12-05 22:38:07 -05:00
|
|
|
have_var("gdbm_version", hdr, hsearch)
|
|
|
|
# gdbm_version is not declared by ndbm.h until gdbm 1.8.3.
|
|
|
|
# We can't include ndbm.h and gdbm.h because they both define datum type.
|
|
|
|
# ndbm.h includes gdbm.h and gdbm_version is declared since gdbm 1.9.
|
|
|
|
have_libvar(["gdbm_version", "char *"], hdr, hsearch)
|
2011-12-06 05:21:12 -05:00
|
|
|
when /\Aqdbm\z/
|
|
|
|
have_var("dpversion", hdr, hsearch)
|
2011-12-05 22:38:07 -05:00
|
|
|
end
|
2011-11-10 01:43:46 -05:00
|
|
|
if hsearch
|
|
|
|
$defs << hsearch
|
|
|
|
@defs = hsearch
|
|
|
|
end
|
2006-09-16 03:14:37 -04:00
|
|
|
$defs << '-DDBM_HDR="<'+hdr+'>"'
|
2011-11-08 09:34:39 -05:00
|
|
|
@found << hdr
|
2006-09-16 03:14:37 -04:00
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
2001-05-02 00:22:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-13 05:58:18 -05:00
|
|
|
if dblib.any? {|db| headers.fetch(db, ["ndbm.h"]).any? {|hdr| headers.db_check(db, hdr) } }
|
2006-09-16 03:14:37 -04:00
|
|
|
have_header("cdefs.h")
|
|
|
|
have_header("sys/cdefs.h")
|
2011-11-11 07:03:51 -05:00
|
|
|
have_func("dbm_pagfno((DBM *)0)", headers.found, headers.defs)
|
|
|
|
have_func("dbm_dirfno((DBM *)0)", headers.found, headers.defs)
|
2011-11-13 09:47:31 -05:00
|
|
|
convertible_int("datum.dsize", headers.found, headers.defs)
|
1998-01-16 07:13:05 -05:00
|
|
|
create_makefile("dbm")
|
|
|
|
end
|