Add BSD license file
[platform/upstream/db4.git] / dist / s_sig
1 #!/bin/sh -
2 #       $Id$
3 #
4 # Build structure signature code.
5
6 a=/tmp/__db_a.$$
7 b=/tmp/__db_b.$$
8 trap 'rm -f $a $b; exit 0' 0 1 2 3 13 15
9
10 cat ../dbinc/db.in ../dbinc/db_int.in ../dbinc/*.h | 
11 sed -e '/__addrinfo/d' \
12     -e '/__aes_cipher/d' \
13     -e '/__cipher/d' \
14     -e '/__queued_output/d' \
15     -e '/__repmgr_connection/d' \
16     -e '/__repmgr_message/d' \
17     -e '/__repmgr_retry/d' \
18     -e '/__repmgr_runnable/d' \
19     -e '/__repmgr_site/d' \
20     -e '/struct.*mutex.*{/i\
21 #ifdef  HAVE_MUTEX_SUPPORT' \
22     -e '/struct.*mutex.*{/a\
23 #endif' \
24     -e 's/.*[    ]*struct[       ]*\(__[a-z_]*\)[        ]*{.*/ __ADD(\1);/p' \
25     -e d > $a
26
27 cnt=`sed -e '$=' -e d $a`
28
29 cat << END_OF_TEXT > $b
30 /*-
31  * DO NOT EDIT: automatically built by dist/s_sig.
32  *
33  * \$Id$
34  */
35
36 #include "db_config.h"
37
38 #define __INCLUDE_NETWORKING    1
39 #define __INCLUDE_SELECT_H      1
40 #include "db_int.h"
41
42 #include "dbinc/db_page.h"
43 #include "dbinc/btree.h"
44 #include "dbinc/crypto.h"
45 #include "dbinc/db_join.h"
46 #include "dbinc/db_verify.h"
47 #include "dbinc/hash.h"
48 #include "dbinc/lock.h"
49 #include "dbinc/log.h"
50 #include "dbinc/mp.h"
51 #include "dbinc/partition.h"
52 #include "dbinc/qam.h"
53 #include "dbinc/txn.h"
54
55 END_OF_TEXT
56
57 echo "#define   __STRUCTURE_COUNT       $cnt" >> $b
58
59 cat << END_OF_TEXT >> $b
60
61 /*
62  * __env_struct_sig --
63  *      Compute signature of structures.
64  *
65  * PUBLIC: u_int32_t __env_struct_sig __P((void));
66  */
67 u_int32_t
68 __env_struct_sig()
69 {
70         u_short t[__STRUCTURE_COUNT + 5];
71         u_int i;
72
73         i = 0;
74 #define __ADD(s)        (t[i++] = sizeof(struct s))
75
76 END_OF_TEXT
77
78 cat $a >> $b
79
80 cat << END_OF_TEXT >> $b
81
82         return (__ham_func5(NULL, t, i * sizeof(t[0])));
83 }
84 END_OF_TEXT
85
86 f=../env/env_sig.c
87 cmp $b $f > /dev/null 2>&1 ||
88     (echo "Building $f" && rm -f $f && cp $b $f && chmod 444 $f)