1 | #!/bin/sh - |
---|
2 | # Id: s_include,v 1.19 2002/03/27 04:31:50 bostic Exp |
---|
3 | # |
---|
4 | # Build the automatically generated function prototype files. |
---|
5 | |
---|
6 | msgc="/* DO NOT EDIT: automatically built by dist/s_include. */" |
---|
7 | |
---|
8 | . ./RELEASE |
---|
9 | |
---|
10 | head() |
---|
11 | { |
---|
12 | defonly=0 |
---|
13 | while : |
---|
14 | do case "$1" in |
---|
15 | space) |
---|
16 | echo ""; shift;; |
---|
17 | defonly) |
---|
18 | defonly=1; shift;; |
---|
19 | *) |
---|
20 | name="$1"; break;; |
---|
21 | esac |
---|
22 | done |
---|
23 | |
---|
24 | echo "$msgc" |
---|
25 | echo "#ifndef $name" |
---|
26 | echo "#define $name" |
---|
27 | echo "" |
---|
28 | if [ $defonly -eq 0 ]; then |
---|
29 | echo "#if defined(__cplusplus)" |
---|
30 | echo "extern \"C\" {" |
---|
31 | echo "#endif" |
---|
32 | echo "" |
---|
33 | fi |
---|
34 | } |
---|
35 | |
---|
36 | tail() |
---|
37 | { |
---|
38 | defonly=0 |
---|
39 | while : |
---|
40 | do case "$1" in |
---|
41 | defonly) |
---|
42 | defonly=1; shift;; |
---|
43 | *) |
---|
44 | name="$1"; break;; |
---|
45 | esac |
---|
46 | done |
---|
47 | |
---|
48 | echo "" |
---|
49 | if [ $defonly -eq 0 ]; then |
---|
50 | echo "#if defined(__cplusplus)" |
---|
51 | echo "}" |
---|
52 | echo "#endif" |
---|
53 | fi |
---|
54 | echo "#endif /* !$name */" |
---|
55 | } |
---|
56 | |
---|
57 | # We are building several files: |
---|
58 | # 1 external #define file |
---|
59 | # 1 external prototype file |
---|
60 | # 1 internal #define file |
---|
61 | # N internal prototype files |
---|
62 | e_dfile=/tmp/__db_c.$$ |
---|
63 | e_pfile=/tmp/__db_a.$$ |
---|
64 | i_dfile=/tmp/__db_d.$$ |
---|
65 | i_pfile=/tmp/__db_b.$$ |
---|
66 | trap 'rm -f $e_dfile $e_pfile $i_dfile $i_pfile; exit 0' 0 1 2 3 13 15 |
---|
67 | |
---|
68 | head defonly space _DB_EXT_DEF_IN_ > $e_dfile |
---|
69 | head space _DB_EXT_PROT_IN_ > $e_pfile |
---|
70 | head defonly _DB_INT_DEF_IN_ > $i_dfile |
---|
71 | |
---|
72 | # Process the standard directories, creating per-directory prototype |
---|
73 | # files and adding to the external prototype and #define files. |
---|
74 | for i in db btree clib common crypto dbreg env fileops hash hmac \ |
---|
75 | lock log mp mutex os qam rep rpc_client rpc_server tcl txn xa; do |
---|
76 | head "_${i}_ext_h_" > $i_pfile |
---|
77 | |
---|
78 | f="../$i/*.c" |
---|
79 | [ $i = os ] && f="$f ../os_win32/*.c" |
---|
80 | [ $i = rpc_server ] && f="../$i/c/*.c" |
---|
81 | [ $i = crypto ] && f="../$i/*.c ../$i/*/*.c" |
---|
82 | awk -f gen_inc.awk \ |
---|
83 | -v db_version_unique_name=$DB_VERSION_UNIQUE_NAME \ |
---|
84 | -v e_dfile=$e_dfile \ |
---|
85 | -v e_pfile=$e_pfile \ |
---|
86 | -v i_dfile=$i_dfile \ |
---|
87 | -v i_pfile=$i_pfile $f |
---|
88 | |
---|
89 | tail "_${i}_ext_h_" >> $i_pfile |
---|
90 | |
---|
91 | f=../dbinc_auto/${i}_ext.h |
---|
92 | cmp $i_pfile $f > /dev/null 2>&1 || |
---|
93 | (echo "Building $f" && rm -f $f && cp $i_pfile $f && chmod 444 $f) |
---|
94 | done |
---|
95 | |
---|
96 | # Process directories which only add to the external prototype and #define |
---|
97 | # files. |
---|
98 | for i in dbm hsearch; do |
---|
99 | f="../$i/*.c" |
---|
100 | awk -f gen_inc.awk \ |
---|
101 | -v db_version_unique_name=$DB_VERSION_UNIQUE_NAME \ |
---|
102 | -v e_dfile=$e_dfile \ |
---|
103 | -v e_pfile=$e_pfile \ |
---|
104 | -v i_dfile="" \ |
---|
105 | -v i_pfile="" $f |
---|
106 | done |
---|
107 | |
---|
108 | # RPC uses rpcgen to generate a header file; post-process it to add more |
---|
109 | # interfaces to the internal #define file. |
---|
110 | sed -e '/extern bool_t xdr___/{' \ |
---|
111 | -e 's/.* //' \ |
---|
112 | -e 's/();//' \ |
---|
113 | -e 's/.*/#define & &@DB_VERSION_UNIQUE_NAME@/' \ |
---|
114 | -e 'p' \ |
---|
115 | -e '}' \ |
---|
116 | -e d < ../dbinc_auto/db_server.h >> $i_dfile |
---|
117 | |
---|
118 | # There are a few globals in DB -- add them to the external/internal |
---|
119 | # #define files. |
---|
120 | (echo "#define __db_global_values __db_global_values@DB_VERSION_UNIQUE_NAME@"; |
---|
121 | echo "#define __db_jump __db_jump@DB_VERSION_UNIQUE_NAME@") >> $i_dfile |
---|
122 | (echo "#define db_xa_switch db_xa_switch@DB_VERSION_UNIQUE_NAME@") >> $e_dfile |
---|
123 | |
---|
124 | # Wrap up the external #defines/prototypes, and internal #defines. |
---|
125 | tail defonly _DB_EXT_DEF_IN_ >> $e_dfile |
---|
126 | f=../dbinc_auto/ext_def.in |
---|
127 | cmp $e_dfile $f > /dev/null 2>&1 || |
---|
128 | (echo "Building $f" && rm -f $f && cp $e_dfile $f && chmod 444 $f) |
---|
129 | |
---|
130 | tail _DB_EXT_PROT_IN_ >> $e_pfile |
---|
131 | f=../dbinc_auto/ext_prot.in |
---|
132 | cmp $e_pfile $f > /dev/null 2>&1 || |
---|
133 | (echo "Building $f" && rm -f $f && cp $e_pfile $f && chmod 444 $f) |
---|
134 | |
---|
135 | tail defonly _DB_INT_DEF_IN_ >> $i_dfile |
---|
136 | f=../dbinc_auto/int_def.in |
---|
137 | cmp $i_dfile $f > /dev/null 2>&1 || |
---|
138 | (echo "Building $f" && rm -f $f && cp $i_dfile $f && chmod 444 $f) |
---|
139 | |
---|
140 | # DB185 compatibility support. |
---|
141 | head space defonly _DB_EXT_185_DEF_IN_ > $e_dfile |
---|
142 | head space _DB_EXT_185_PROT_IN_ > $e_pfile |
---|
143 | |
---|
144 | f="../db185/*.c" |
---|
145 | awk -f gen_inc.awk \ |
---|
146 | -v db_version_unique_name=$DB_VERSION_UNIQUE_NAME \ |
---|
147 | -v e_dfile=$e_dfile \ |
---|
148 | -v e_pfile=$e_pfile \ |
---|
149 | -v i_dfile="" \ |
---|
150 | -v i_pfile="" $f |
---|
151 | |
---|
152 | tail defonly _DB_EXT_185_DEF_IN_ >> $e_dfile |
---|
153 | f=../dbinc_auto/ext_185_def.in |
---|
154 | cmp $e_dfile $f > /dev/null 2>&1 || |
---|
155 | (echo "Building $f" && rm -f $f && cp $e_dfile $f && chmod 444 $f) |
---|
156 | |
---|
157 | tail _DB_EXT_185_PROT_IN_ >> $e_pfile |
---|
158 | f=../dbinc_auto/ext_185_prot.in |
---|
159 | cmp $e_pfile $f > /dev/null 2>&1 || |
---|
160 | (echo "Building $f" && rm -f $f && cp $e_pfile $f && chmod 444 $f) |
---|