This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove spurious LINT: directives
[metaconfig.git] / U / perl / i_db.U
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 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.
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 contains cat \
26         Compile d_const 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
94 set db.h i_db
95 eval $inhdr
96
97 case "$i_db" in
98 $define)
99         : Check db version.
100         echo " "
101         echo "Checking Berkeley DB version ..." >&4
102         $cat >try.c <<EOCP
103 #$d_const HASCONST
104 #ifndef HASCONST
105 #define const
106 #endif
107 #include <sys/types.h>
108 #include <stdio.h>
109 #$i_stdlib I_STDLIB
110 #ifdef I_STDLIB
111 #include <stdlib.h>
112 #endif
113 #include <db.h>
114 int main(int argc, char *argv[])
115 {
116 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
117     int Major, Minor, Patch ;
118     unsigned long Version ;
119     (void)db_version(&Major, &Minor, &Patch) ;
120     if (argc == 2) {
121         printf("%d %d %d %d %d %d\n",
122                DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
123                Major, Minor, Patch);
124         exit(0);
125     }
126     printf("You have Berkeley DB Version 2 or greater.\n");
127
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) ;
132
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") ;
136         exit(3);
137     }
138
139     printf("db.h and libdb are compatible.\n") ;
140
141     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
142                 + DB_VERSION_PATCH ;
143
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") ;
148         exit(2);
149     }
150
151     exit(0);
152 #else
153 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
154     if (argc == 2) {
155         printf("1 0 0\n");
156         exit(0);
157     }
158     printf("You have Berkeley DB Version 1.\n");
159     exit(0);    /* DB version < 2: the coast is clear. */
160 #else
161     exit(1);    /* <db.h> not Berkeley DB? */
162 #endif
163 #endif
164 }
165 EOCP
166         set try
167         if eval $compile_ok && $run ./try; then
168                 echo 'Looks OK.' >&4
169                 set `$run ./try 1`
170                 db_version_major=$1
171                 db_version_minor=$2
172                 db_version_patch=$3
173         else
174                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
175                 i_db=$undef
176                 case " $libs " in
177                 *"-ldb "*)
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$//'`
181                         shift
182                         libs="$*"
183                         echo "libs = $libs" >&4
184                         ;;
185                 esac
186         fi
187         $rm_try
188         ;;
189 esac
190
191 @if DB_Hash_t
192 case "$i_db" in
193 define)
194         : Check the return type needed for hash
195         echo " "
196         echo "Checking return type needed for hash for Berkeley DB ..." >&4
197         $cat >try.c <<EOCP
198 #$d_const HASCONST
199 #ifndef HASCONST
200 #define const
201 #endif
202 #include <sys/types.h>
203 #include <db.h>
204
205 #ifndef DB_VERSION_MAJOR
206 u_int32_t hash_cb (ptr, size)
207 const void *ptr;
208 size_t size;
209 {
210 }
211 HASHINFO info;
212 int main()
213 {
214         info.hash = hash_cb;
215 }
216 #endif
217 EOCP
218         if $cc $ccflags -c try.c >try.out 2>&1 ; then
219                 if $contains warning try.out >>/dev/null 2>&1 ; then
220                         db_hashtype='int'
221                 else
222                         db_hashtype='u_int32_t'
223                 fi
224         else
225                 : XXX Maybe we should just give up here.
226                 db_hashtype=u_int32_t
227                 $cat try.out >&4
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
230         fi
231         $rm_try
232         echo "Your version of Berkeley DB uses $db_hashtype for hash."
233         ;;
234 *)      db_hashtype=u_int32_t
235         ;;
236 esac
237 @end
238 @if DB_Prefix_t
239 case "$i_db" in
240 define)
241         : Check the return type needed for prefix
242         echo " "
243         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
244         cat >try.c <<EOCP
245 #$d_const HASCONST
246 #ifndef HASCONST
247 #define const
248 #endif
249 #include <sys/types.h>
250 #include <db.h>
251
252 #ifndef DB_VERSION_MAJOR
253 size_t prefix_cb (key1, key2)
254 const DBT *key1;
255 const DBT *key2;
256 {
257 }
258 BTREEINFO info;
259 int main()
260 {
261         info.prefix = prefix_cb;
262 }
263 #endif
264 EOCP
265         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
266                 if $contains warning try.out >>/dev/null 2>&1 ; then
267                         db_prefixtype='int'
268                 else
269                         db_prefixtype='size_t'
270                 fi
271         else
272                 db_prefixtype='size_t'
273                 : XXX Maybe we should just give up here.
274                 $cat try.out >&4
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
277         fi
278         $rm_try
279         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
280         ;;
281 *)      db_prefixtype='size_t'
282         ;;
283 esac
284 @end
285