Debian Codegraph @

dist/s_windows

raw
1 #!/bin/sh -
2 # $Id$
3 #
4 # Build Windows include files.
5
6 msgc="/* DO NOT EDIT: automatically built by dist/s_windows. */"
7 msgw="; DO NOT EDIT: automatically built by dist/s_windows."
8
9 . ./RELEASE
10
11 s=/tmp/__db_a$$
12 t=/tmp/__db_b$$
13 rm -f $s $t
14
15 trap 'rm -f $s $t ; exit 1' 1 2 3 13 15
16
17 # Build the Windows db.h
18 cat <<ENDOFSEDTEXT > $s
19 /@inttypes_h_decl@/d
20 /@stdint_h_decl@/d
21 s/@stddef_h_decl@/#include <stddef.h>/
22 /@unistd_h_decl@/d
23 /@thread_h_decl@/d
24 s/@u_int8_decl@/typedef unsigned char u_int8_t;/
25 s/@int16_decl@/typedef short int16_t;/
26 s/@u_int16_decl@/typedef unsigned short u_int16_t;/
27 s/@int32_decl@/typedef int int32_t;/
28 s/@u_int32_decl@/typedef unsigned int u_int32_t;/
29 s/@int64_decl@/typedef __int64 int64_t;/
30 s/@u_int64_decl@/typedef unsigned __int64 u_int64_t;/
31 s/@db_seq_decl@/typedef int64_t db_seq_t;/
32 s/@db_threadid_t_decl@/typedef u_int32_t db_threadid_t;/
33 s/@pid_t_decl@/typedef int32_t pid_t;/
34 /@u_char_decl@/{
35 i\\
36 #ifndef _WINSOCKAPI_
37 s/@u_char_decl@/typedef unsigned char u_char;/
38 }
39 s/@u_short_decl@/typedef unsigned short u_short;/
40 s/@u_int_decl@/typedef unsigned int u_int;/
41 /@u_long_decl@/{
42 s/@u_long_decl@/typedef unsigned long u_long;/
43 a\\
44 #endif
45 }
46 /@FILE_t_decl@/d
47 /@size_t_decl@/d
48 /@ssize_t_decl@/{
49 i\\
50 #ifdef _WIN64\\
51 typedef int64_t ssize_t;\\
52 #else\\
53 typedef int32_t ssize_t;\\
54 #endif
55 d
56 }
57
58 /@time_t_decl@/d
59 /@uintmax_t_decl@/{
60 i\\
61 #if defined(_MSC_VER) && _MSC_VER < 1300\\
62 typedef u_int32_t uintmax_t;\\
63 #else\\
64 typedef u_int64_t uintmax_t;\\
65 #endif
66 d
67 }
68 /@uintptr_t_decl@/{
69 i\\
70 #ifdef _WIN64\\
71 typedef u_int64_t uintptr_t;\\
72 #else\\
73 typedef u_int32_t uintptr_t;\\
74 #endif
75 d
76 }
77 /@off_t_decl@/{
78 i\\
79 /*\\
80 \ * Windows defines off_t to long (i.e., 32 bits). We need to pass 64-bit\\
81 \ * file offsets, so we declare our own.\\
82 \ */\\
83 #define off_t __db_off_t\\
84 typedef int64_t off_t;
85 d
86 }
87 /@platform_header@/{
88 i\\
89 /*\\
90 \ * Turn off inappropriate compiler warnings\\
91 \ */\\
92 #ifdef _MSC_VER\\
93 /*\\
94 \ * This warning is explicitly disabled in Visual C++ by default.\\
95 \ * It is necessary to explicitly enable the /Wall flag to generate this\\
96 \ * warning.\\
97 \ * Since this is a shared include file it should compile without warnings\\
98 \ * at the highest warning level, so third party applications can use\\
99 \ * higher warning levels cleanly.\\
100 \ *\\
101 \ * 4820: 'bytes' bytes padding added after member 'member'\\
102 \ * The type and order of elements caused the compiler to\\
103 \ * add padding to the end of a struct.\\
104 \ */\\
105 #pragma warning(push)\\
106 #pragma warning(disable: 4820)\\
107 #endif /* _MSC_VER */
108 d
109 }
110 /@platform_footer@/{
111 i\\
112 /* Restore default compiler warnings */\\
113 #ifdef _MSC_VER\\
114 #pragma warning(pop)\\
115 #endif
116 d
117 }
118 s/@DB_VERSION_FAMILY@/$DB_VERSION_FAMILY/
119 s/@DB_VERSION_RELEASE@/$DB_VERSION_RELEASE/
120 s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/
121 s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/
122 s/@DB_VERSION_PATCH@/$DB_VERSION_PATCH/
123 s/@DB_VERSION_STRING@/"$DB_VERSION_STRING"/
124 s/@DB_VERSION_FULL_STRING@/"$DB_VERSION_FULL_STRING"/
125 s/@DB_VERSION_UNIQUE_NAME@//
126 s/@DB_CONST@//
127 s/@DB_PROTO1@/#undef __P/
128 s/@DB_PROTO2@/#define __P(protos) protos/
129 ENDOFSEDTEXT
130 # The db.h, db_int.h files are identical between Windows and WinCE.
131 # This may change in the future, for now have the script copy
132 # the headers into the build_wince directory.
133 # WinCE does not support the C++ API, so don't need to copy db_cxx.h
134
135 (echo "$msgc" &&
136 sed -f $s ../src/dbinc/db.in &&
137 cat ../src/dbinc_auto/api_flags.in &&
138 cat ../src/dbinc_auto/ext_prot.in) > $t
139 test `egrep '@.*@' $t` && {
140 egrep '@.*@' $t
141 echo 'Unexpanded autoconf variables found in Windows db.h.'
142 exit 1
143 }
144 f=../build_windows/db.h
145 cmp $t $f > /dev/null 2>&1 ||
146 (echo "Building $f" && rm -f $f && cp $t $f)
147 f=../build_wince/db.h
148 cmp $t $f > /dev/null 2>&1 ||
149 (echo "Building $f" && rm -f $f && cp $t $f)
150
151 # Build the Windows db_cxx.h.
152 cat <<ENDOFSEDTEXT > $s
153 s/@cxx_have_stdheaders@/#define HAVE_CXX_STDHEADERS 1/
154 ENDOFSEDTEXT
155 (echo "$msgc" && sed -f $s ../src/dbinc/db_cxx.in) > $t
156 test `egrep '@.*@' $t` && {
157 egrep '@.*@' $t
158 echo 'Unexpanded autoconf variables found in Windows db_cxx.h.'
159 exit 1
160 }
161 f=../build_windows/db_cxx.h
162 cmp $t $f > /dev/null 2>&1 ||
163 (echo "Building $f" && rm -f $f && cp $t $f)
164
165 # Build the Windows db_int.h.
166 cat <<ENDOFSEDTEXT > $s
167 s/@DB_STRUCT_ALIGN8@/__declspec(align(8))/
168 s/@PATH_SEPARATOR@/\\\\\\\\\/:/
169 s/@db_int_def@//
170 ENDOFSEDTEXT
171 (echo "$msgc" && sed -f $s ../src/dbinc/db_int.in) > $t
172 test `egrep '@.*@' $t` && {
173 egrep '@.*@' $t
174 echo 'Unexpanded autoconf variables found in Windows db_int.h.'
175 exit 1
176 }
177 f=../build_windows/db_int.h
178 cmp $t $f > /dev/null 2>&1 ||
179 (echo "Building $f" && rm -f $f && cp $t $f)
180 f=../build_wince/db_int.h
181 cmp $t $f > /dev/null 2>&1 ||
182 (echo "Building $f" && rm -f $f && cp $t $f)
183
184 # Build the Windows and WinCE db_config.h.
185 # We don't fail, but we complain if the win_config.in file isn't up-to-date.
186 check_config()
187 {
188 egrep '^#undef' config.hin | awk '{print $2}' | sort -u > $s
189 (egrep '#undef' $1 | awk '{print $3}'
190 egrep '^#define' $1 | awk '{print $2}') | sed '/__STDC__/d' | sort -u > $t
191 cmp $s $t > /dev/null || {
192 echo "config.hin and $1 differ"
193 echo "<<< config.hin >>> $1"
194 diff $s $t
195 }
196 }
197 check_config win_config.in
198 f=../build_windows/db_config.h
199 (echo "$msgc" && sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" win_config.in) > $t
200 cmp $t $f > /dev/null 2>&1 ||
201 (echo "Building $f" && rm -f $f && cp $t $f)
202 check_config wince_config.in
203 f=../build_wince/db_config.h
204 (echo "$msgc" && sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" wince_config.in) > $t
205 cmp $t $f > /dev/null 2>&1 ||
206 (echo "Building $f" && rm -f $f && cp $t $f)
207
208 # Build the Windows libdb.rc, libdb.def and libdb_small.def.
209 f=../build_windows/libdb.rc
210 cat <<ENDOFSEDTEXT > $s
211 s/%MAJOR%/$DB_VERSION_MAJOR/
212 s/%MINOR%/$DB_VERSION_MINOR/
213 s/%PATCH%/$DB_VERSION_PATCH/
214 ENDOFSEDTEXT
215 sed -f $s ../build_windows/libdbrc.src > $t
216 cmp $t $f > /dev/null 2>&1 ||
217 (echo "Building $f" && rm -f $f && cp $t $f)
218 f=../build_windows/libdb.def
219 (echo $msgw &&
220 echo &&
221 echo EXPORTS;
222 a=1
223 for i in `sed -e '/^$/d' -e '/^#/d' -e 's/[ ].*//' win_exports.in`; do
224 echo " $i @$a"
225 a=`expr $a + 1`
226 done) > $t
227 cmp $t $f > /dev/null 2>&1 ||
228 (echo "Building $f" && rm -f $f && cp $t $f)
229 f=../build_windows/libdb_small.def
230 (echo $msgw &&
231 echo &&
232 echo EXPORTS;
233 a=1
234 for i in `sed -e '/^$/d' -e '/^#/d' win_exports.in |
235 egrep -w db_small |
236 sed -e 's/[ ].*//'`; do
237 echo " $i @$a"
238 a=`expr $a + 1`
239 done) > $t
240 cmp $t $f > /dev/null 2>&1 ||
241 (echo "Building $f" && rm -f $f && cp $t $f)
242
243 # Build the Windows clib_port.h.
244 cat <<ENDOFSEDTEXT > $s
245 s/@INT64_FMT@/#define INT64_FMT "%I64d"/
246 s/@UINT64_FMT@/#define UINT64_FMT "%I64u"/
247 ENDOFSEDTEXT
248 sed -f $s clib_port.in > $t
249 test `egrep '@.*@' $t` && {
250 egrep '@.*@' $t
251 echo 'Unexpanded autoconf variables found in Windows clib_port.h.'
252 exit 1
253 }
254 f=../build_windows/clib_port.h
255 cmp $t $f > /dev/null 2>&1 ||
256 (echo "Building $f" && rm -f $f && cp $t $f)
257 f=../build_wince/clib_port.h
258 cmp $t $f > /dev/null 2>&1 ||
259 (echo "Building $f" && rm -f $f && cp $t $f)
260
261 # Build the Windows dbstl_common.h.
262 cat <<ENDOFSEDTEXT > $s
263 s/@WSTRING_decl@/#define HAVE_WSTRING 1/
264 s/@TLS_decl@/#define TLS_DECL_MODIFIER __declspec(thread)/
265 s/@TLS_defn@/#define TLS_DEFN_MODIFIER __declspec(thread)/
266 ENDOFSEDTEXT
267 sed -f $s ../lang/cxx/stl/dbstl_common.in > $t
268 f=../build_windows/dbstl_common.h
269 cmp $t $f > /dev/null 2>&1 ||
270 (echo "Building $f" && rm -f $f && cp $t $f)
271
272 # Copy in errno.h.
273 f=../build_wince/errno.h
274 cmp errno.h $f > /dev/null 2>&1 ||
275 (echo "Building $f" && rm -f $f && cp errno.h $f)
276
277 rm -f $s $t