1 ?RCS: $Id: i_db.U,v 3.0.1.3 1995/07/25 14:10:22 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu>
13 ?RCS: $Log: i_db.U,v $
14 ?RCS: Revision 3.0.1.3 1995/07/25 14:10:22 ram
15 ?RCS: patch56: conditionally use const in test programs (ADO)
17 ?RCS: Revision 3.0.1.2 1995/05/12 12:14:42 ram
18 ?RCS: patch54: extended for more intimate DB probing (ADO)
20 ?RCS: Revision 3.0.1.1 1994/08/29 16:21:50 ram
21 ?RCS: patch32: created by ADO
23 ?MAKE:i_db db_hashtype db_prefixtype \
24 db_version_major db_version_minor db_version_patch : \
25 Inhdr +cc +ccflags rm_try contains cat \
26 Compile d_const libs sed run i_stdlib
27 ?MAKE: -pick add $@ %<
29 ?S: This variable conditionally defines the I_DB symbol, and indicates
30 ?S: whether a C program may include Berkeley's DB include file <db.h>.
33 ?S: This variable contains the type of the hash structure element
34 ?S: in the <db.h> header file. In older versions of DB, it was
35 ?S: int, while in newer ones it is u_int32_t.
38 ?S: This variable contains the type of the prefix structure element
39 ?S: in the <db.h> header file. In older versions of DB, it was
40 ?S: int, while in newer ones it is size_t.
43 ?S: This variable contains the major version number of
44 ?S: Berkeley DB found in the <db.h> header file.
47 ?S: This variable contains the minor version number of
48 ?S: Berkeley DB found in the <db.h> header file.
49 ?S: For DB version 1 this is always 0.
52 ?S: This variable contains the patch version number of
53 ?S: Berkeley DB found in the <db.h> header file.
54 ?S: For DB version 1 this is always 0.
57 ?C: This symbol, if defined, indicates to the C program that it should
58 ?C: include Berkeley's DB include file <db.h>.
61 ?C: This symbol contains the type of the prefix structure element
62 ?C: in the <db.h> header file. In older versions of DB, it was
63 ?C: int, while in newer ones it is u_int32_t.
66 ?C: This symbol contains the type of the prefix structure element
67 ?C: in the <db.h> header file. In older versions of DB, it was
68 ?C: int, while in newer ones it is size_t.
70 ?C:DB_VERSION_MAJOR_CFG:
71 ?C: This symbol, if defined, defines the major version number of
72 ?C: Berkeley DB found in the <db.h> header when Perl was configured.
74 ?C:DB_VERSION_MINOR_CFG:
75 ?C: This symbol, if defined, defines the minor version number of
76 ?C: Berkeley DB found in the <db.h> header when Perl was configured.
77 ?C: For DB version 1 this is always 0.
79 ?C:DB_VERSION_PATCH_CFG:
80 ?C: This symbol, if defined, defines the patch version number of
81 ?C: Berkeley DB found in the <db.h> header when Perl was configured.
82 ?C: For DB version 1 this is always 0.
85 ?H:#define DB_Hash_t $db_hashtype /**/
86 ?H:#define DB_Prefix_t $db_prefixtype /**/
87 ?H:#define DB_VERSION_MAJOR_CFG $db_version_major /**/
88 ?H:#define DB_VERSION_MINOR_CFG $db_version_minor /**/
89 ?H:#define DB_VERSION_PATCH_CFG $db_version_patch /**/
93 : see if this is a db.h system
101 echo "Checking Berkeley DB version ..." >&4
107 #include <sys/types.h>
114 int main(int argc, char *argv[])
116 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
117 int Major, Minor, Patch ;
118 unsigned long Version ;
119 (void)db_version(&Major, &Minor, &Patch) ;
121 printf("%d %d %d %d %d %d\n",
122 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
123 Major, Minor, Patch);
126 printf("You have Berkeley DB Version 2 or greater.\n");
128 printf("db.h is from Berkeley DB Version %d.%d.%d\n",
129 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
130 printf("libdb is from Berkeley DB Version %d.%d.%d\n",
131 Major, Minor, Patch) ;
133 /* check that db.h & libdb are compatible */
134 if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
135 printf("db.h and libdb are incompatible.\n") ;
139 printf("db.h and libdb are compatible.\n") ;
141 Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
144 /* needs to be >= 2.3.4 */
145 if (Version < 2003004) {
146 /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
147 printf("Perl needs Berkeley DB 2.3.4 or greater.\n") ;
153 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
158 printf("You have Berkeley DB Version 1.\n");
159 exit(0); /* DB version < 2: the coast is clear. */
161 exit(1); /* <db.h> not Berkeley DB? */
167 if eval $compile_ok && $run ./try; then
174 echo "I can't use Berkeley DB with your <db.h>. I'll disable Berkeley DB." >&4
178 : Remove db from list of libraries to use
179 echo "Removing unusable -ldb from library list" >&4
180 set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
183 echo "libs = $libs" >&4
194 : Check the return type needed for hash
196 echo "Checking return type needed for hash for Berkeley DB ..." >&4
202 #include <sys/types.h>
205 #ifndef DB_VERSION_MAJOR
206 u_int32_t hash_cb (ptr, size)
218 if $cc $ccflags -c try.c >try.out 2>&1 ; then
219 if $contains warning try.out >>/dev/null 2>&1 ; then
222 db_hashtype='u_int32_t'
225 : XXX Maybe we should just give up here.
226 db_hashtype=u_int32_t
228 echo "Help: I can't seem to compile the db test program." >&4
229 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
232 echo "Your version of Berkeley DB uses $db_hashtype for hash."
234 *) db_hashtype=u_int32_t
241 : Check the return type needed for prefix
243 echo "Checking return type needed for prefix for Berkeley DB ..." >&4
249 #include <sys/types.h>
252 #ifndef DB_VERSION_MAJOR
253 size_t prefix_cb (key1, key2)
261 info.prefix = prefix_cb;
265 if $cc $ccflags -c try.c >try.out 2>&1 ; then
266 if $contains warning try.out >>/dev/null 2>&1 ; then
269 db_prefixtype='size_t'
272 db_prefixtype='size_t'
273 : XXX Maybe we should just give up here.
275 echo "Help: I can't seem to compile the db test program." >&4
276 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
279 echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
281 *) db_prefixtype='size_t'