Add BSD license file
[platform/upstream/db4.git] / dist / s_winmsi
1 #!/bin/bash -
2 #       $Id$
3 #
4 # Note: The s_winmsi script in Berkeley DB core closely parallels the
5 # s_winmsi script in Berkeley DB/XML.  If you change one,
6 # consider whether your changes apply to the other.
7 # As of this writing, the two s_winmsi scripts 'diff' very closely, and
8 # identical portions have been factored into functions in s_winmsi.fcn.
9 #
10 #   Usage: s_winmsi [ options ]
11 #
12 # See the Usage() function in s_winmsi.fcn for a full list of options.
13 # By default, this script expects a db-X.Y.Z.zip file
14 # to be in this directory, and uses it to build all binaries
15 # needed for an Windows install, and finally builds the an
16 # output db-X.Y.Z.msi file that can be installed on
17 # Windows XP and 2000.
18 #
19 # The major other inputs to this script are these files:
20 #
21 #   features.in        list of choosable features (like Java,PHP,...)
22 #   files.in           what files are in each feature and where they belong
23 #   links.in           a list of URLs that end up as part of the Start Menu
24 #   environment.in     a list of environment vars that must be set
25 #
26 # This script does a number of operations, using the directory
27 # './winmsi/stage' as a staging area:
28 #
29 #   extracts the contents of the input ZIP file and uses those
30 #   files (minus docs/...) to build a Sources directory for
31 #   the Sources features.
32 #
33 #   builds Berkeley DB using Visual Studio tools using a .BAT
34 #   script derived from winbuild.in .
35 #
36 #   builds Perl and other APIs .
37 #
38 #   uses {features,files,links,environment}.in to build some include
39 #   files in WiX XML format.  These files are named
40 #   *.wixinc (e.g. directory.wixinc)
41 #
42 #   run m4 on dbcorewix.in to create dbcore.wxs .  dbcorewix.in
43 #   uses m4 macros to allow reasonable refactoring of repeated
44 #   UI code.  Also, m4 is used to include the files created in
45 #   the previous step.
46 #
47 #   Use the WiX compiler/linker on the .wxs files to create the .msi file.
48 #
49 ################################################################
50
51 # Define all needed shell functions
52 . ./winmsi/s_winmsi.fcn
53
54 ERRORLOG="$0".log
55 SetupErrorLog
56
57 # Do this before parsing options, we need the version number
58 . ./RELEASE
59 dbver=db-$DB_VERSION
60
61 # Set variables used by functions to customize this installer
62 PRODUCT_NAME="Berkeley DB"
63 PRODUCT_VERSION="$DB_VERSION"
64 PRODUCT_STAGE=`pwd`/winmsi/stage
65 PRODUCT_LICENSEDIR="${PRODUCT_STAGE}/$dbver"
66 PRODUCT_SUB_BLDDIR="${PRODUCT_STAGE}/$dbver"
67 PRODUCT_BLDDIR="${PRODUCT_STAGE}/$dbver"
68 PRODUCT_SRCDIR="${PRODUCT_STAGE}/$dbver"
69 PRODUCT_DBBUILDDIR="${PRODUCT_STAGE}/$dbver/build_unix"
70 PRODUCT_SHARED_WINMSIDIR=`pwd`/winmsi
71 PRODUCT_IMAGEDIR=$PRODUCT_SHARED_WINMSIDIR/images
72 PRODUCT_ZIP_FILEFMT="db-X.Y.Z.zip"
73 PRODUCT_MSI_FILEFMT="db-X.Y.Z.msi"
74 PRODUCT_MSVC_VERSION=71
75
76 PRODUCT_MAJOR=`echo "$PRODUCT_VERSION" | \
77     sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'`
78 PRODUCT_MINOR=`echo "$PRODUCT_VERSION" | \
79     sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'`
80 PRODUCT_PATCH=`echo "$PRODUCT_VERSION" | \
81     sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'`
82 PRODUCT_MAJMIN="${PRODUCT_MAJOR}${PRODUCT_MINOR}"
83
84 # Gather command line options, and use reasonable defaults
85 SetupOptions \
86         -input "$dbver.zip" \
87         -output "$dbver.msi" \
88         "$@"
89
90 if [ "$OPT_USEBUILD" != '' ]; then
91     PRODUCT_BLDDIR="${OPT_USEBUILD}"
92     PRODUCT_SUB_BLDDIR="${OPT_USEBUILD}"
93 fi
94
95 # Choose the MS runtime libraries to use.
96 if [ -e "/cygdrive/c/Program Files/Microsoft Visual Studio 8/Common7/Tools/vsvars32.bat" ]; then
97     MSVC_ROOT_DIR="/cygdrive/c/Program Files/Microsoft Visual Studio 8/"
98     PRODUCT_MSVC_VERSION=80
99 fi
100
101 Progress "s_winmsi starting, errors to $ERRORLOG"
102
103 # Fail fast for certain missing files
104
105 RequireCygwin
106 RequireJava
107 RequireTcl
108 RequireWix
109 RequirePerl
110
111 CreateStage
112 cd ${PRODUCT_STAGE}
113
114
115 CreateSources ${PRODUCT_STAGE}/Sources
116
117 # The docs are put into a separate feature set
118 mv ${PRODUCT_STAGE}/Sources/docs ${PRODUCT_STAGE}/
119
120 # Build everything unless we were told to use a preexisting build
121 if [ "$OPT_USEBUILD" = '' ]; then
122     CreateWindowsBuild
123     CreateWindowsSystem
124     CreateInclude \
125         ${PRODUCT_SUB_BLDDIR}/installed_include \
126         ${PRODUCT_SUB_BLDDIR}/dbinc/* \
127         ${PRODUCT_SUB_BLDDIR}/dbinc_auto/* \
128         ${PRODUCT_SUB_BLDDIR}/build_windows/*.h \
129         ${PRODUCT_SUB_BLDDIR}/stl/*.h
130     CreateDbPerl
131 fi
132
133 if ! "$OPT_SKIPGEN" ; then
134   CreateLicenseRtf ../../../LICENSE license.rtf
135   CreateWixIncludeFiles
136 fi
137
138 CreateMsi ../dbcorewix.in dbcore.wxs "$OPT_OUTFILE"
139
140 Progress "s_winmsi finished, $OPT_OUTFILE created."
141 exit 0
142