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
|
2011-11-13 11:25:40 +04:00
|
|
|
dblib = %w(libc 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 = {
|
2011-11-14 15:22:15 +04:00
|
|
|
"libc" => ["ndbm.h"], # 4.4BSD libc contains Berkeley DB 1.
|
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"],
|
2011-11-14 15:22:15 +04:00
|
|
|
"dbm" => ["ndbm.h"], # traditional ndbm (4.3BSD)
|
2011-11-12 11:50:12 +04: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 15:58:15 +03:00
|
|
|
"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
|
2011-11-10 10:43:46 +04:00
|
|
|
attr_accessor :defs
|
2011-11-08 18:34:39 +04:00
|
|
|
end
|
|
|
|
headers.found = []
|
2011-11-10 10:43:46 +04:00
|
|
|
headers.defs = nil
|
2011-11-07 15:17:17 +04:00
|
|
|
|
2011-11-13 14:58:18 +04:00
|
|
|
def headers.db_check(db, hdr)
|
2011-11-13 10:41:19 +04:00
|
|
|
old_libs = $libs.dup
|
|
|
|
old_defs = $defs.dup
|
2011-11-13 14:58:18 +04:00
|
|
|
result = db_check2(db, hdr)
|
2011-11-13 07:47:07 +04:00
|
|
|
if !result
|
|
|
|
$libs = old_libs
|
|
|
|
$defs = old_defs
|
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2011-11-13 14:58:18 +04:00
|
|
|
def headers.db_check2(db, hdr)
|
2006-09-16 11:14:37 +04:00
|
|
|
hsearch = nil
|
2001-05-07 14:56:01 +04:00
|
|
|
|
|
|
|
case db
|
2010-06-11 19:40:39 +04:00
|
|
|
when /^db[2-5]?$/
|
2011-11-10 10:43:46 +04:00
|
|
|
hsearch = "-DDB_DBM_HSEARCH"
|
2002-12-13 20:14:18 +03:00
|
|
|
when "gdbm_compat"
|
|
|
|
have_library("gdbm") or return false
|
2001-05-02 08:22:21 +04:00
|
|
|
end
|
2006-09-16 11:14:37 +04:00
|
|
|
|
2011-11-17 15:45:32 +04:00
|
|
|
if have_type("DBM", hdr, hsearch) and
|
2011-11-13 11:25:40 +04:00
|
|
|
(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
|
|
|
|
have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch)) and
|
2011-11-12 11:06:09 +04:00
|
|
|
have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
|
2011-11-10 10:43:46 +04:00
|
|
|
if hsearch
|
|
|
|
$defs << hsearch
|
|
|
|
@defs = hsearch
|
|
|
|
end
|
2006-09-16 11:14:37 +04:00
|
|
|
$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
|
|
|
|
|
2011-11-13 14:58:18 +04:00
|
|
|
if dblib.any? {|db| headers.fetch(db, ["ndbm.h"]).any? {|hdr| headers.db_check(db, hdr) } }
|
2006-09-16 11:14:37 +04:00
|
|
|
have_header("cdefs.h")
|
|
|
|
have_header("sys/cdefs.h")
|
2011-11-11 16:03:51 +04:00
|
|
|
have_func("dbm_pagfno((DBM *)0)", headers.found, headers.defs)
|
|
|
|
have_func("dbm_dirfno((DBM *)0)", headers.found, headers.defs)
|
2011-11-13 18:47:31 +04:00
|
|
|
convertible_int("datum.dsize", headers.found, headers.defs)
|
1998-01-16 15:13:05 +03:00
|
|
|
create_makefile("dbm")
|
|
|
|
end
|