#!/bin/bash -
############################################################
# Build Windows Binary Distribution for BDB XML
#
# Assumes current dir is dbxml/dist inside a clean, unzipped 
# tree from a source distribution package
#
# Usage:  bash s_winmsi []
# 
# Steps:
#  1. Build release and debug binaries (including java and php)
#  2. Build additional included languages (perl, python)
#  3. Build, or check .wxs file (uses Python)
#  4. Build .msi
#
# dbxml-version.msi ends up in $PRODUCT_BLDDIR/wix
#
# Options:
#  TBD -- add some
############################################################

#
# Get utility functions
#
. winmsi/s_winmsi_dbxml.fcn

ERRORLOG=winmsi.log
SetupErrorLog

# Do this before parsing options, we need the version number
. ./RELEASE
dbver=dbxml-$DBXML_VERSION

# Set variables used by functions to customize this installer
PRODUCT_NAME="Berkeley DB XML"
PRODUCT_VERSION="$DBXML_VERSION"
PRODUCT_STAGE=`pwd`/../..
PRODUCT_LICENSEDIR="${PRODUCT_STAGE}"
PRODUCT_BLDDIR="${PRODUCT_STAGE}"
DIST_DIR=`pwd`

Progress "s_winmsi starting, errors to $ERRORLOG"

SetDbXmlDir

Progress "Building from $PRODUCT_BLDDIR, dbxml is $PRODUCT_SUB_BLDDIR"

RequireCygwin
RequireJava
RequireWix
RequirePython
RequirePerl

#
# Build from source
#
BuildDbXml

#
# Copy dependent system libraries to build for packaging
#
CreateWindowsSystem

#
# Build Perl
#
CreateDbXmlPerl

#
# Build Python
#
CreateDbXmlPython

#
# Fixup Examples
#
FixupExamples

#
# Build the license file as rtf
#
CreateLicenseRtf ../LICENSE License.rtf

#
# Build runtime .wxs files
#
CreateRuntimeComponents

#
# Create the .msi
#
CreateMsi

Progress "s_winmsi finished, $OPT_OUTFILE created."
exit 0

