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