summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/dbm/extconf.rb45
2 files changed, 48 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fbf8d521f..1fdf29940f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Feb 17 21:18:39 2012 Tanaka Akira <akr@fsij.org>
+
+ * ext/dbm/extconf.rb: refine header/libraty mismatch detection.
+ check only for ndbm.h except libc. check _GDBM_H_ for gdbm.
+ check _DBM_IOERR for the original ndbm.
+
Fri Feb 17 20:30:44 2012 Tanaka Akira <akr@fsij.org>
* ext/dbm/extconf.rb: don't check libdbm. It is not a ndbm
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 9e8da8505c..e2ffc2b3ed 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -79,18 +79,57 @@ def headers.db_check2(db, hdr)
return false
end
+ # 'libc' means ndbm is provided by libc.
+ # 4.3BSD original ndbm is contained in libc.
+ # 4.4BSD (and its derivatives such as NetBSD) contains Berkeley DB 1 in libc.
if !(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch))
return false
end
+ # Skip a mismatch of Berkeley DB's ndbm.h and old gdbm library.
+ #
+ # dbm_clearerr() should be available for any ndbm implementation.
+ # It is available since the original (4.3BSD) ndbm and standardized by POSIX.
+ #
+ # However "can't resolve symbol 'dbm_clearerr'" problem may be caused by
+ # header/library mismatch: Berkeley DB ndbm.h and gdbm library until 1.8.3.
+ # gdbm (until 1.8.3) provides dbm_clearerr() as a empty macro in the header
+ # and the library don't provide dbm_clearerr().
+ # Berkeley DB provides dbm_clearerr() as a usual function.
+ # So Berkeley DB header with gdbm library causes the problem.
+ #
if !have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
return false
end
- # _DB_H_ should not be defined except Berkeley DB.
- if !(/\Adb\d?\z/ =~ db || db == 'libc' || !have_macro('_DB_H_', hdr, hsearch))
- return false
+ # ndbm.h is provided by the original (4.3BSD) dbm,
+ # Berkeley DB 1 in libc of 4.4BSD and
+ # ndbm compatibility layer of gdbm.
+ # So, try to check header/library mismatch.
+ #
+ # Assumption: There are no insane environment which libc provides ndbm
+ # functions but ndbm.h is not for that.
+ #
+ if hdr == 'ndbm.h' && db != 'libc'
+ # Berkeley DB's ndbm.h (since 1.85 at least) includes db.h and
+ # it defines _DB_H_.
+ if /\Adb\d?\z/ !~ db && have_macro('_DB_H_', hdr, hsearch)
+ return false
+ end
+
+ # Recent GDBM's ndbm.h, since 1.9, includes gdbm.h and it defines _GDBM_H_.
+ # ndbm compatibility layer of GDBM is provided by libgdbm (until 1.8.0)
+ # and libgdbm_compat (since 1.8.1).
+ if /\Agdbm/ !~ db && have_macro('_GDBM_H_', hdr, hsearch)
+ return false
+ end
+
+ # 4.3BSD's ndbm.h defines _DBM_IOERR.
+ # The original ndbm is provided by libc in 4.3BSD.
+ if have_macro('_DBM_IOERR', hdr, hsearch)
+ return false
+ end
end
case db