summaryrefslogtreecommitdiff
path: root/ext/dbm/extconf.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-17 12:29:50 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-17 12:29:50 +0000
commit6d1f751207de36053d061657691603a47a4c6496 (patch)
treef4ae976aa9fe8b8199bad23b26df011b97c7d768 /ext/dbm/extconf.rb
parentfbca1d0da135b29f311dff5afcc6d6a3cbc597c7 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm/extconf.rb')
-rw-r--r--ext/dbm/extconf.rb45
1 files changed, 42 insertions, 3 deletions
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 9e8da85..e2ffc2b 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