4 # Build Windows include files.
6 msgc="/* DO NOT EDIT: automatically built by dist/s_windows. */"
7 msgw="; DO NOT EDIT: automatically built by dist/s_windows."
15 trap 'rm -f $s $t ; exit 1' 1 2 3 13 15
17 # Build the Windows db.h
18 cat <<ENDOFSEDTEXT > $s
21 s/@stddef_h_decl@/#include <stddef.h>/
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 int pid_t;/
37 s/@u_char_decl@/typedef unsigned char u_char;/
39 s/@u_short_decl@/typedef unsigned short u_short;/
40 s/@u_int_decl@/typedef unsigned int u_int;/
42 s/@u_long_decl@/typedef unsigned long u_long;/
51 typedef int64_t ssize_t;\\
53 typedef int32_t ssize_t;\\
60 #if defined(_MSC_VER) && _MSC_VER < 1300\\
61 typedef u_int32_t uintmax_t;\\
63 typedef u_int64_t uintmax_t;\\
70 typedef u_int64_t uintptr_t;\\
72 typedef u_int32_t uintptr_t;\\
79 \ * Windows defines off_t to long (i.e., 32 bits). We need to pass 64-bit\\
80 \ * file offsets, so we declare our own.\\
82 #define off_t __db_off_t\\
83 typedef int64_t off_t;
89 \ * Turn off inappropriate compiler warnings\\
93 \ * This warning is explicitly disabled in Visual C++ by default.\\
94 \ * It is necessary to explicitly enable the /Wall flag to generate this\\
96 \ * Since this is a shared include file it should compile without warnings\\
97 \ * at the highest warning level, so third party applications can use\\
98 \ * higher warning levels cleanly.\\
100 \ * 4820: 'bytes' bytes padding added after member 'member'\\
101 \ * The type and order of elements caused the compiler to\\
102 \ * add padding to the end of a struct.\\
104 #pragma warning(push)\\
105 #pragma warning(disable: 4820)\\
106 #endif /* _MSC_VER */
111 /* Restore default compiler warnings */\\
113 #pragma warning(pop)\\
117 s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/
118 s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/
119 s/@DB_VERSION_PATCH@/$DB_VERSION_PATCH/
120 s/@DB_VERSION_STRING@/"$DB_VERSION_STRING"/
121 s/@DB_VERSION_UNIQUE_NAME@//
123 s/@DB_PROTO1@/#undef __P/
124 s/@DB_PROTO2@/#define __P(protos) protos/
126 # The db.h, db_int.h files are identical between Windows and WinCE.
127 # This may change in the future, for now have the script copy
128 # the headers into the build_wince directory.
129 # WinCE does not support the C++ API, so don't need to copy db_cxx.h
132 sed -f $s ../dbinc/db.in &&
133 cat ../dbinc_auto/api_flags.in &&
134 cat ../dbinc_auto/ext_prot.in) > $t
135 test `egrep '@.*@' $t` && {
137 echo 'Unexpanded autoconf variables found in Windows db.h.'
140 f=../build_windows/db.h
141 cmp $t $f > /dev/null 2>&1 ||
142 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
143 f=../build_wince/db.h
144 cmp $t $f > /dev/null 2>&1 ||
145 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
147 # Build the Windows db_cxx.h.
148 cat <<ENDOFSEDTEXT > $s
149 s/@cxx_have_stdheaders@/#define HAVE_CXX_STDHEADERS 1/
151 (echo "$msgc" && sed -f $s ../dbinc/db_cxx.in) > $t
152 test `egrep '@.*@' $t` && {
154 echo 'Unexpanded autoconf variables found in Windows db_cxx.h.'
157 f=../build_windows/db_cxx.h
158 cmp $t $f > /dev/null 2>&1 ||
159 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
161 # Build the Windows db_int.h.
162 cat <<ENDOFSEDTEXT > $s
163 s/@PATH_SEPARATOR@/\\\\\\\\\/:/
166 (echo "$msgc" && sed -f $s ../dbinc/db_int.in) > $t
167 test `egrep '@.*@' $t` && {
169 echo 'Unexpanded autoconf variables found in Windows db_int.h.'
172 f=../build_windows/db_int.h
173 cmp $t $f > /dev/null 2>&1 ||
174 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
175 f=../build_wince/db_int.h
176 cmp $t $f > /dev/null 2>&1 ||
177 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
179 # Build the Windows and WinCE db_config.h.
180 # We don't fail, but we complain if the win_config.in file isn't up-to-date.
183 egrep '^#undef' config.hin | awk '{print $2}' | sort > $s
184 (egrep '#undef' $1 | awk '{print $3}'
185 egrep '^#define' $1 | awk '{print $2}') | sed '/__STDC__/d' | sort > $t
186 cmp $s $t > /dev/null || {
187 echo "config.hin and $1 differ"
188 echo "<<< config.hin >>> $1"
192 check_config win_config.in
193 f=../build_windows/db_config.h
194 (echo "$msgc" && sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" win_config.in) > $t
195 cmp $t $f > /dev/null 2>&1 ||
196 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
197 check_config wince_config.in
198 f=../build_wince/db_config.h
199 (echo "$msgc" && sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" wince_config.in) > $t
200 cmp $t $f > /dev/null 2>&1 ||
201 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
203 # Build the Windows libdb.rc and libdb.def.
204 f=../build_windows/libdb.rc
205 cat <<ENDOFSEDTEXT > $s
206 s/%MAJOR%/$DB_VERSION_MAJOR/
207 s/%MINOR%/$DB_VERSION_MINOR/
208 s/%PATCH%/$DB_VERSION_PATCH/
210 sed -f $s ../build_windows/libdbrc.src > $t
211 cmp $t $f > /dev/null 2>&1 ||
212 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
213 f=../build_windows/libdb.def
218 for i in `sed -e '/^$/d' -e '/^#/d' win_exports.in`; do
222 cmp $t $f > /dev/null 2>&1 ||
223 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
225 # Build the Windows clib_port.h.
226 cat <<ENDOFSEDTEXT > $s
227 s/@INT64_FMT@/#define INT64_FMT "%I64d"/
228 s/@UINT64_FMT@/#define UINT64_FMT "%I64u"/
230 sed -f $s clib_port.in > $t
231 test `egrep '@.*@' $t` && {
233 echo 'Unexpanded autoconf variables found in Windows clib_port.h.'
236 f=../build_windows/clib_port.h
237 cmp $t $f > /dev/null 2>&1 ||
238 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
239 f=../build_wince/clib_port.h
240 cmp $t $f > /dev/null 2>&1 ||
241 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
243 # Build the Windows dbstl_common.h.
244 cat <<ENDOFSEDTEXT > $s
245 s/@WSTRING_decl@/#define HAVE_WSTRING 1/
246 s/@TLS_decl@/#define TLS_DECL_MODIFIER __declspec(thread)/
247 s/@TLS_defn@/#define TLS_DEFN_MODIFIER __declspec(thread)/
249 sed -f $s ../stl/dbstl_common.in > $t
250 f=../build_windows/dbstl_common.h
251 cmp $t $f > /dev/null 2>&1 ||
252 (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
255 f=../build_wince/errno.h
256 cmp errno.h $f > /dev/null 2>&1 ||
257 (echo "Building $f" && rm -f $f && cp errno.h $f && chmod 444 $f)