?RCS: $Id: i_db.U,v 3.0.1.3 1995/07/25 14:10:22 ram Exp $ ?RCS: ?RCS: Copyright (c) 1991-1993, Raphael Manfredi ?RCS: ?RCS: You may redistribute only under the terms of the Artistic Licence, ?RCS: as specified in the README file that comes with the distribution. ?RCS: You may reuse parts of this distribution only within the terms of ?RCS: that same Artistic Licence; a copy of which may be found at the root ?RCS: of the source tree for dist 3.0. ?RCS: ?RCS: Original Author: Andy Dougherty ?RCS: ?RCS: $Log: i_db.U,v $ ?RCS: Revision 3.0.1.3 1995/07/25 14:10:22 ram ?RCS: patch56: conditionally use const in test programs (ADO) ?RCS: ?RCS: Revision 3.0.1.2 1995/05/12 12:14:42 ram ?RCS: patch54: extended for more intimate DB probing (ADO) ?RCS: ?RCS: Revision 3.0.1.1 1994/08/29 16:21:50 ram ?RCS: patch32: created by ADO ?RCS: ?MAKE:i_db db_hashtype db_prefixtype: Inhdr +cc +ccflags rm contains cat \ Compile d_const libs sed ?MAKE: -pick add $@ %< ?S:i_db: ?S: This variable conditionally defines the I_DB symbol, and indicates ?S: whether a C program may include Berkeley's DB include file . ?S:. ?S:db_hashtype: ?S: This variable contains the type of the hash structure element ?S: in the header file. In older versions of DB, it was ?S: int, while in newer ones it is u_int32_t. ?S:. ?S:db_prefixtype: ?S: This variable contains the type of the prefix structure element ?S: in the header file. In older versions of DB, it was ?S: int, while in newer ones it is size_t. ?S:. ?C:I_DB: ?C: This symbol, if defined, indicates to the C program that it should ?C: include Berkeley's DB include file . ?C:. ?C:DB_Prefix_t: ?C: This symbol contains the type of the prefix structure element ?C: in the header file. In older versions of DB, it was ?C: int, while in newer ones it is u_int32_t. ?C:. ?C:DB_Hash_t: ?C: This symbol contains the type of the prefix structure element ?C: in the header file. In older versions of DB, it was ?C: int, while in newer ones it is size_t. ?C:. ?H:#$i_db I_DB /**/ ?H:#define DB_Hash_t $db_hashtype /**/ ?H:#define DB_Prefix_t $db_prefixtype /**/ ?H:. ?LINT:set i_db ?LINT:change libs : see if this is a db.h system set db.h i_db eval $inhdr case "$i_db" in $define) : Check db version. echo " " echo "Checking Berkeley DB version ..." >&4 $cat >try.c < #include #include int main() { #ifdef DB_VERSION_MAJOR /* DB version >= 2 */ int Major, Minor, Patch ; unsigned long Version ; (void)db_version(&Major, &Minor, &Patch) ; printf("You have Berkeley DB Version 2 or greater\n"); printf("db.h is from Berkeley DB Version %d.%d.%d\n", DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH); printf("libdb is from Berkeley DB Version %d.%d.%d\n", Major, Minor, Patch) ; /* check that db.h & libdb are compatible */ if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) { printf("db.h and libdb are incompatible\n") ; exit(3); } printf("db.h and libdb are compatible\n") ; Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000 + DB_VERSION_PATCH ; /* needs to be >= 2.3.4 */ if (Version < 2003004) { /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */ printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ; exit(2); } exit(0); #else #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC) printf("You have Berkeley DB Version 1\n"); exit(0); /* DB version < 2: the coast is clear. */ #else exit(1); /* not Berkeley DB? */ #endif #endif } EOCP set try if eval $compile_ok && ./try; then echo 'Looks OK.' >&4 else echo "I can't use Berkeley DB with your . I'll disable Berkeley DB." >&4 i_db=$undef case " $libs " in *"-ldb "*) : Remove db from list of libraries to use echo "Removing unusable -ldb from library list" >&4 set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'` shift libs="$*" echo "libs = $libs" >&4 ;; esac fi $rm -f try.* ;; esac @if DB_Hash_t case "$i_db" in define) : Check the return type needed for hash echo " " echo "Checking return type needed for hash for Berkeley DB ..." >&4 $cat >try.c < #include #ifndef DB_VERSION_MAJOR u_int32_t hash_cb (ptr, size) const void *ptr; size_t size; { } HASHINFO info; int main() { info.hash = hash_cb; } #endif EOCP if $cc $ccflags -c try.c >try.out 2>&1 ; then if $contains warning try.out >>/dev/null 2>&1 ; then db_hashtype='int' else db_hashtype='u_int32_t' fi else : XXX Maybe we should just give up here. db_hashtype=u_int32_t $cat try.out >&4 echo "Help: I can't seem to compile the db test program." >&4 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4 fi $rm -f try.* echo "Your version of Berkeley DB uses $db_hashtype for hash." ;; *) db_hashtype=u_int32_t ;; esac @end @if DB_Prefix_t case "$i_db" in define) : Check the return type needed for prefix echo " " echo "Checking return type needed for prefix for Berkeley DB ..." >&4 cat >try.c < #include #ifndef DB_VERSION_MAJOR size_t prefix_cb (key1, key2) const DBT *key1; const DBT *key2; { } BTREEINFO info; int main() { info.prefix = prefix_cb; } #endif EOCP if $cc $ccflags -c try.c >try.out 2>&1 ; then if $contains warning try.out >>/dev/null 2>&1 ; then db_prefixtype='int' else db_prefixtype='size_t' fi else db_prefixtype='size_t' : XXX Maybe we should just give up here. $cat try.out >&4 echo "Help: I can't seem to compile the db test program." >&4 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4 fi $rm -f try.* echo "Your version of Berkeley DB uses $db_prefixtype for prefix." ;; *) db_prefixtype='size_t' ;; esac @end