From: nobu.nokada@... Date: 2003-07-23T15:40:31+09:00 Subject: Re: Bug report: ruby-1.8.0p3 fails to compile under FreeBSD-4.7 Hi, At Wed, 23 Jul 2003 00:20:39 +0900, Brian Candler wrote: > On this box, DBM is defined in /usr/include/ndbm.h: > > typedef DB DBM; > > It in turn includes , which defines DB and DBT. > > Editing the ext/dbm/Makefile manually, so that it has -DDBM_HDR="", > allows the compile to continue. Does this patch work? Index: lib/mkmf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/mkmf.rb,v retrieving revision 1.138 diff -u -2 -p -r1.138 mkmf.rb --- lib/mkmf.rb 23 Jul 2003 05:19:22 -0000 1.138 +++ lib/mkmf.rb 23 Jul 2003 06:35:30 -0000 @@ -250,4 +250,58 @@ def cpp_include(header) end +def try_static_assert(expr, headers = nil, opt = "") + headers = cpp_include(headers) + try_compile(< #{(upper+lower)/2}", headers, opt) + lower = (upper+lower)/2 + else + upper = (upper+lower)/2 + end + end + upper = -upper if neg + return upper + else + src = %{#{COMMON_HEADERS} +#{cpp_include(headers)} +#include +int main() {printf("%d\\n", (int)(#{const})); return 0;} +} + if try_link0(src, opt) + xpopen("./conftest") do |f| + return Integer(f.gets) + end + end + end + nil +end + def try_func(func, libs, headers = nil) headers = cpp_include(headers) @@ -443,4 +497,36 @@ SRC end +def have_type(type, header=nil, opt="") + checking_for type do + if try_compile(<<"SRC", opt) or try_compile(<<"SRC", opt) +#{COMMON_HEADERS} +#{cpp_include(header)} +static #{type} t; +SRC +#{COMMON_HEADERS} +#{cpp_include(header)} +static #{type} *t; +SRC + $defs.push(format("-DHAVE_TYPE_%s", type.upcase)) + true + else + false + end + end +end + +def check_sizeof(type, header=nil) + expr = "sizeof(#{type})" + m = "checking size of #{type}... " + message "%s", m + Logging::message "check_sizeof: %s--------------------\n", m + if size = try_constant(expr, header) + $defs.push(format("-DSIZEOF_%s", type.upcase)) + end + message(a = size ? "#{size}\n" : "failed\n") + Logging::message "-------------------- %s\n", a + r +end + def find_executable0(bin, path = nil) path = (path || ENV['PATH']).split(File::PATH_SEPARATOR) Index: ext/dbm/extconf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/ext/dbm/extconf.rb,v retrieving revision 1.15 diff -u -2 -p -r1.15 extconf.rb --- ext/dbm/extconf.rb 7 Jul 2003 01:30:02 -0000 1.15 +++ ext/dbm/extconf.rb 23 Jul 2003 06:37:03 -0000 @@ -33,5 +33,5 @@ def db_check(db) if have_library(db, db_prefix("dbm_open")) || have_func(db_prefix("dbm_open")) for hdr in $dbm_conf_headers.fetch(db, ["ndbm.h"]) - if have_header(hdr.dup) + if have_header(hdr.dup) and have_type("DBM", hdr.dup, hsearch) $CFLAGS += " " + hsearch + '-DDBM_HDR="<'+hdr+'>"' return true -- Nobu Nakada