1#!/bin/bash - 2# $Id$ 3# 4# Build Windows .dsp files. 5# Build Windows Mobile .dsp and .vcproj files 6# Build Windows .vcproj files. 7 8. RELEASE 9 10SRCFILES=srcfiles.in 11 12create_dsp() 13{ 14 projname="$1" # name of the .dsp file 15 match="$2" # the string used to egrep the $sources file 16 sources="$3" # a modified version of $SRCFILES to facilitate matches 17 dsptemplate="$4" # overall template file for the .dsp 18 extra_cppflags="$5" # extra flags to send to compiler 19 release_libs="$6" # libraries to link against in Release builds 20 debug_libs="$7" # libraries to link against in Debug builds 21 lib_suffix="$8" # the library name is libdb@lib_suffix@@VERSION@ 22 proj_type="$9" # the project type dsp or vcp 23 proj_guid="${10}" # The project guid for VS2005 projects 24 25 # Set the default project type to be "dsp" 26 if [ ! "$proj_type" ] ; then 27 proj_type=dsp 28 fi 29 30 # template file for the src file fragments 31 srctemplate="$BUILDDIR/srcfile_$proj_type.src" 32 rsrctemplate="$BUILDDIR/rsrcfile_$proj_type.src" 33 dspoutput=$BUILDDIR/$projname.$proj_type 34 35 postbuild=$dspoutput.postbuild 36 if [ ! -f $postbuild ] ; then 37 postbuild=/dev/null 38 fi 39 40 rm -f $dspoutput.insert 41 for srcpath in `egrep "$match" $sources | sed -e 's/[ ].*//'` 42 do 43 # take the path name and break it up, converting / to \\. 44 # so many backslashes needed because of shell quoting and 45 # sed quoting -- we'll end up with two backslashes for every 46 # forward slash, but we need that when feeding that to the 47 # later sed command. 48 set - `echo $srcpath | sed -e 's;\(.*\)/;../\\1 ;' \ 49 -e "s;$BUILDDIR;.;" \ 50 -e 's;/;\\\\\\\\;g'` 51 srcdir="$1" 52 srcfile="$2" 53 if [ "${srcfile##*.}" = "rc" -a "$proj_type" = "vcproj" ] ; then 54 inptemplate=$rsrctemplate 55 else 56 inptemplate=$srctemplate 57 fi 58 59 sed -e "s/@srcdir@/$srcdir/g" \ 60 -e "s/@srcfile@/$srcfile/g" \ 61 < $inptemplate >> $dspoutput.insert 62 done 63 sed -e "/@SOURCE_FILES@/r$dspoutput.insert" \ 64 -e "/@SOURCE_FILES@/d" \ 65 -e "/@POST_BUILD@/r$postbuild" \ 66 -e "/@POST_BUILD@/d" \ 67 -e "s/@project_name@/$projname/g" \ 68 -e "s,@extra_cppflags@,$extra_cppflags,g" \ 69 -e "s,@release_libs@,$release_libs,g" \ 70 -e "s,@debug_libs@,$debug_libs,g" \ 71 -e "s,@lib_suffix@,$lib_suffix,g" \ 72 -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \ 73 -e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \ 74 -e "s/@PROJ_GUID@/$proj_guid/g" \ 75 < $dsptemplate > $dspoutput.new 76 77 # We run this script on Windows (under Cygwin). Fix up the line-endings 78 # for the temporary files. We don't test the platform, just run unix2dos 79 # if the command exists, ignoring any not-found error message. 80 (unix2dos.exe $dspoutput.new) >/dev/null 2>&1 81 82 # Set the file mode to 644 because the VC++ IDE needs a writeable file 83 # in our development environment. 84 cmp $dspoutput.new $dspoutput > /dev/null 2>&1 || 85 (echo "Building $dspoutput" && rm -f $dspoutput && 86 cp $dspoutput.new $dspoutput && chmod 664 $dspoutput) 87 rm -f $dspoutput.insert $dspoutput.new 88} 89 90TMPA=/tmp/swindsp$$a 91trap "rm -f $TMPA; exit 1" 1 2 3 15 92 93# create a copy of the srcfiles with comments and empty lines removed. 94# add a space at the end of each list of modules so that each module 95# can be unambiguously matched e.g. ' dynamic ' 96sed -e "s/#.*$//" \ 97 -e "/^[ ]*$/d" \ 98 -e "s/[ ][ ]*/ /" \ 99 -e "s/[ ]*$//" \ 100 -e "/[ ]/!d" \ 101 -e "s/$/ /" < $SRCFILES > $TMPA 102 103# get a list of all modules mentioned 104# 105MODULES="`sed -e 's/^[^ ]* //' < $TMPA | tr ' ' '\012' | sort | uniq`" 106 107for module in $MODULES 108do 109 case "$module" in 110 dynamic ) 111 BUILDDIR=../build_windows 112 create_dsp db_dll " $module " $TMPA $BUILDDIR/dynamic_dsp.src \ 113 '' 'ws2_32.lib' 'ws2_32.lib' 114 ;; 115 small ) 116 BUILDDIR=../build_windows 117 create_dsp db_small " $module " $TMPA $BUILDDIR/static_dsp.src \ 118 '/D "HAVE_SMALLBUILD"' '' '' _small 119 ;; 120 static ) 121 BUILDDIR=../build_windows 122 create_dsp db_static " $module " $TMPA $BUILDDIR/static_dsp.src 123 ;; 124 ce) 125 BUILDDIR=../build_wince 126 create_dsp db_static " $module " $TMPA \ 127 ../build_wince/static_vcp.src '' '' '' '' vcp 128 # Build VS2005 projects. 129 # The GUID passed in must match that in the .sln workspace. 130 # It would be ideal to grab the GUID from there if this 131 # project is already included there. 132 create_dsp db_static " $module " $TMPA \ 133 ../build_wince/static_vcproj.src '' '' '' '' vcproj \ 134 "4AB4958F-8DD0-49B5-8C02-014B5637C59A" 135 ;; 136 ce_small) 137 BUILDDIR=../build_wince 138 create_dsp db_small " $module " $TMPA \ 139 ../build_wince/static_vcp.src '/D "HAVE_SMALLBUILD"' \ 140 '' '' _small vcp 141 # Build VS2005 projects. 142 # The GUID passed in must match that in the .sln workspace. 143 # It would be ideal to grab the GUID from there if this 144 # project is already included there. 145 create_dsp db_small " $module " $TMPA \ 146 ../build_wince/static_vcproj.src 'HAVE_SMALLBUILD' \ 147 '' '' _small vcproj "6A2849DA-8F7C-4B50-BDAE-AE7752EF8213" 148 ;; 149 java ) 150 BUILDDIR=../build_windows 151 create_dsp db_java " $module " $TMPA $BUILDDIR/dynamic_dsp.src '' \ 152 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@.lib' \ 153 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@d.lib' _java 154 ;; 155 tcl ) 156 BUILDDIR=../build_windows 157 create_dsp db_tcl " $module " $TMPA $BUILDDIR/dynamic_dsp.src \ 158 '/D "DB_TCL_SUPPORT"' \ 159 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@.lib tcl84.lib' \ 160 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@d.lib tcl84g.lib' _tcl 161 ;; 162 testutil ) 163 BUILDDIR=../build_windows 164 create_dsp db_test " $module " $TMPA $BUILDDIR/app_dsp.src \ 165 '' '/out:"Win32\\Release\\dbkill.exe"' '/out:"Win32\\Debug\\dbkill.exe"' 166 ;; 167 app=* ) 168 BUILDDIR=../build_windows 169 appname=`echo $module | sed -e 's/^app=//'` 170 case "$appname" in 171 ex_rep_base ) 172 libs='ws2_32.lib' 173 ;; 174 * ) 175 libs='' 176 ;; 177 esac 178 # Split into Windows CE and Win32/64 project creation. 179 case "$appname" in 180 wce_tpcb ) 181 BUILDDIR=../build_wince 182 create_dsp $appname " $module " $TMPA \ 183 ../build_wince/app_vcp.src '/D "__NO_SYSTEM_INCLUDES"' \ 184 '' '' '' vcp 185 # The GUID passed in must match that in the .sln workspace. 186 # It would be ideal to grab the GUID from there if this 187 # project is already included there. 188 create_dsp $appname " $module " $TMPA \ 189 ../build_wince/app_vcproj.src '__NO_SYSTEM_INCLUDES' \ 190 '' '' '' vcproj "F2CE670A-ABAE-414A-9A17-8079AB58613F" 191 BUILDDIR=../build_windows 192 ;; 193 * ) 194 create_dsp $appname " $module " $TMPA $BUILDDIR/app_dsp.src \ 195 '' $libs $libs 196 ;; 197 esac 198 ;; 199 brew|s60|vx|vxsmall|vx6 ) 200 ;; 201 * ) 202 echo \ 203 "s_windows_dsp: module name $module in $SRCFILES is unknown type" 204 ;; 205 esac 206done 207 208rm -f $TMPA 209 210# 211# Drive construction of Visual Studio (version 7.1) projects 212# files, using an xquery script (genproject.template),an input XML 213# document, and a file containing a list of project names. 214# 215 216# Source the Berkeley DB release version numbers. 217cd win_projects 218 219# project name list 220PROJECTS=db.projects 221 222# xquery script template, called genproject.template in DBXML tree. 223TEMPLATE=genproject.template 224 225# temporary script, post-sed-replacement 226TEMP_SCRIPT=genproject.script 227 228# xml document input template, called dbxml.template.xml in DBXML tree. 229CONFIG_INPUT=projects.template.xml 230 231# temporary xml document, post-sed-replacement, called dbxml.projects in DBXML 232CONFIG_OUTPUT=projects.xml 233 234# location for output project files 235PROJECT_OUTPUT_DIR=../../build_windows 236 237# substitute some variables in the XML document template 238sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \ 239 -e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \ 240 < $CONFIG_INPUT > $CONFIG_OUTPUT 241 242echo "Building Visual Studio project files -- " 243echo " output only for modified projects (this can take a while)" 244 245# for each project, substitute 2 variables in the XQuery script, then run it 246for v in VC8 247do 248 if [ $v = "VC7.1" ]; then 249 VERSION="7.10" 250 else 251 VERSION="8.00" 252 fi 253 254 echo "Building for Visual Studio version $VERSION" 255 256 for i in `cat $PROJECTS` 257 do 258 sed -e "s!@PROJECT_NAME@!$i!g" -e "s!@PROJECT_INPUT@!$CONFIG_OUTPUT!g" -e "s!@VISUAL_STUDIO_VERSION@!$VERSION!g" < $TEMPLATE > $TEMP_SCRIPT 259 TMP=$PROJECT_OUTPUT_DIR/$i.tmp.vcproj 260 if [ $v = "VC7.1" ]; then 261 TARG=$PROJECT_OUTPUT_DIR/${i}_vs71.vcproj 262 else 263 TARG=$PROJECT_OUTPUT_DIR/${i}.vcproj 264 fi 265 xqilla -o $TMP $TEMP_SCRIPT 266 rm -f $TEMP_SCRIPT 267 cmp $TMP $TARG > /dev/null 2>&1 || 268 (echo "Building $TARG" && rm -f $TARG && 269 cp $TMP $TARG && chmod 664 $TARG) 270 rm -f $TMP 271 done 272done 273 274# Cleanup. 275rm -f $CONFIG_OUTPUT 276cd .. 277