This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
/\=/ does not require \ even in older awk
[metaconfig.git] / U / perl / i_db.U
... / ...
CommitLineData
1?RCS: $Id: i_db.U,v 3.0.1.3 1995/07/25 14:10:22 ram Exp $
2?RCS:
3?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic License,
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 License; a copy of which may be found at the root
9?RCS: of the source tree for dist 3.0.
10?RCS:
11?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu>
12?RCS:
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)
16?RCS:
17?RCS: Revision 3.0.1.2 1995/05/12 12:14:42 ram
18?RCS: patch54: extended for more intimate DB probing (ADO)
19?RCS:
20?RCS: Revision 3.0.1.1 1994/08/29 16:21:50 ram
21?RCS: patch32: created by ADO
22?RCS:
23?MAKE:i_db db_hashtype db_prefixtype \
24 db_version_major db_version_minor db_version_patch : \
25 Inhdr +cc +ccflags rm_try compiler_warning cat \
26 Compile libs sed run i_stdlib
27?MAKE: -pick add $@ %<
28?S:i_db:
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>.
31?S:.
32?S:db_hashtype:
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.
36?S:.
37?S:db_prefixtype:
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.
41?S:.
42?S:db_version_major:
43?S: This variable contains the major version number of
44?S: Berkeley DB found in the <db.h> header file.
45?S:.
46?S:db_version_minor:
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.
50?S:.
51?S:db_version_patch:
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.
55?S:.
56?C:I_DB:
57?C: This symbol, if defined, indicates to the C program that it should
58?C: include Berkeley's DB include file <db.h>.
59?C:.
60?C:DB_Prefix_t:
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.
64?C:.
65?C:DB_Hash_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.
69?C:.
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.
73?C:.
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.
78?C:.
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.
83?C:.
84?H:#$i_db I_DB /**/
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 /**/
90?H:.
91?F:!try
92?LINT:change libs
93: see if this is a db.h system
94set db.h i_db
95eval $inhdr
96
97case "$i_db" in
98$define)
99 : Check db version.
100 echo " "
101 echo "Checking Berkeley DB version ..." >&4
102 $cat >try.c <<EOCP
103#include <sys/types.h>
104#include <stdio.h>
105#$i_stdlib I_STDLIB
106#ifdef I_STDLIB
107#include <stdlib.h>
108#endif
109#include <db.h>
110int main(int argc, char *argv[])
111{
112#ifdef DB_VERSION_MAJOR /* DB version >= 2 */
113 int Major, Minor, Patch ;
114 unsigned long Version ;
115 (void)db_version(&Major, &Minor, &Patch) ;
116 if (argc == 2) {
117 printf("%d %d %d %d %d %d\n",
118 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
119 Major, Minor, Patch);
120 exit(0);
121 }
122 printf("You have Berkeley DB Version 2 or greater.\n");
123
124 printf("db.h is from Berkeley DB Version %d.%d.%d\n",
125 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
126 printf("libdb is from Berkeley DB Version %d.%d.%d\n",
127 Major, Minor, Patch) ;
128
129 /* check that db.h & libdb are compatible */
130 if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
131 printf("db.h and libdb are incompatible.\n") ;
132 exit(3);
133 }
134
135 printf("db.h and libdb are compatible.\n") ;
136
137 Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
138 + DB_VERSION_PATCH ;
139
140 /* needs to be >= 2.3.4 */
141 if (Version < 2003004) {
142 /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
143 printf("Perl needs Berkeley DB 2.3.4 or greater.\n") ;
144 exit(2);
145 }
146
147 exit(0);
148#else
149#if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
150 if (argc == 2) {
151 printf("1 0 0\n");
152 exit(0);
153 }
154 printf("You have Berkeley DB Version 1.\n");
155 exit(0); /* DB version < 2: the coast is clear. */
156#else
157 exit(1); /* <db.h> not Berkeley DB? */
158#endif
159#endif
160}
161EOCP
162 set try
163 if eval $compile_ok && $run ./try; then
164 echo 'Looks OK.' >&4
165 set `$run ./try 1`
166 db_version_major=$1
167 db_version_minor=$2
168 db_version_patch=$3
169 else
170 echo "I can't use Berkeley DB with your <db.h>. I'll disable Berkeley DB." >&4
171 i_db=$undef
172 case " $libs " in
173 *"-ldb "*)
174 : Remove db from list of libraries to use
175 echo "Removing unusable -ldb from library list" >&4
176 set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
177 shift
178 libs="$*"
179 echo "libs = $libs" >&4
180 ;;
181 esac
182 fi
183 $rm_try
184 ;;
185esac
186
187@if DB_Hash_t
188case "$i_db" in
189define)
190 : Check the return type needed for hash
191 echo " "
192 echo "Checking return type needed for hash for Berkeley DB ..." >&4
193 $cat >try.c <<EOCP
194#include <sys/types.h>
195#include <db.h>
196
197#ifndef DB_VERSION_MAJOR
198u_int32_t hash_cb (const void* ptr, size_t size)
199{
200 return 0;
201}
202HASHINFO info;
203int main()
204{
205 info.hash = hash_cb;
206}
207#endif
208EOCP
209 if $cc $ccflags -c try.c >try.out 2>&1 ; then
210 if $compiler_warning try.out >>/dev/null 2>&1 ; then
211 db_hashtype='int'
212 else
213 db_hashtype='u_int32_t'
214 fi
215 else
216 : XXX Maybe we should just give up here.
217 db_hashtype=u_int32_t
218 $cat try.out >&4
219 echo "Help: I can't seem to compile the db test program." >&4
220 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
221 fi
222 $rm_try
223 echo "Your version of Berkeley DB uses $db_hashtype for hash."
224 ;;
225*) db_hashtype=u_int32_t
226 ;;
227esac
228@end
229@if DB_Prefix_t
230case "$i_db" in
231define)
232 : Check the return type needed for prefix
233 echo " "
234 echo "Checking return type needed for prefix for Berkeley DB ..." >&4
235 cat >try.c <<EOCP
236#include <sys/types.h>
237#include <db.h>
238
239#ifndef DB_VERSION_MAJOR
240size_t prefix_cb (const DBT *key1, const DBT *key2)
241{
242 return 0;
243}
244BTREEINFO info;
245int main()
246{
247 info.prefix = prefix_cb;
248}
249#endif
250EOCP
251 if $cc $ccflags -c try.c >try.out 2>&1 ; then
252 if $compiler_warning try.out >>/dev/null 2>&1 ; then
253 db_prefixtype='int'
254 else
255 db_prefixtype='size_t'
256 fi
257 else
258 db_prefixtype='size_t'
259 : XXX Maybe we should just give up here.
260 $cat try.out >&4
261 echo "Help: I can't seem to compile the db test program." >&4
262 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
263 fi
264 $rm_try
265 echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
266 ;;
267*) db_prefixtype='size_t'
268 ;;
269esac
270@end
271