@echo off
rem (c) Copyright IBM Corp. 2007 All rights reserved.
rem 
rem The following sample of source code ("Sample") is owned by International 
rem Business Machines Corporation or one of its subsidiaries ("IBM") and is 
rem copyrighted and licensed, not sold. You may use, copy, modify, and 
rem distribute the Sample in any form without payment to IBM, for the purpose of 
rem assisting you in the development of your applications.
rem 
rem The Sample code is provided to you on an "AS IS" basis, without warranty of 
rem any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR 
rem IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
rem MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Some jurisdictions do 
rem not allow for the exclusion or limitation of implied warranties, so the above 
rem limitations or exclusions may not apply to you. IBM shall not be liable for 
rem any damages you suffer as a result of using, copying, modifying or 
rem distributing the Sample, even if IBM has been advised of the possibility of 
rem such damages.

rem BATCH FILE: bldmc.bat
rem Builds C++ multi-connection application on Windows
rem Requires a second database: db_alias2. Suggested name: sample2
rem Also requires three program source files: prog_name and prog_name1 to be
rem bound to the first database; prog_name2 to be bound to the second database

rem Default compiler is set to Microsoft Visual C++
rem To use a different compiler, comment out 'set BLDCOMP=cl'
rem and uncomment 'set BLDCOMP=icl'�or 'set BLDCOMP=ecl'
rem Microsoft C/C++ Compiler
set BLDCOMP=cl

rem Intel C++ Compiler for 32-bit and 64-bit applications
rem set BLDCOMP=icl

rem Older Intel C++ Compiler for Itanium 64-bit applications
rem set BLDCOMP=ecl

rem Uncomment the next line if building 32-bit applications using
rem a DB2 64-bit product on Windows 64-bit
rem set BITWIDTH=32onWin64

rem The INCLUDE path environment variable must have 
rem %DB2PATH%\include ahead of any Microsoft Platform SDK
rem include directories.
rem set INCLUDE=%DB2PATH%\include;%INCLUDE%

rem On ntx64 use bufferoverflowU.lib library during linking
set BUFFEROVERFLOWLIB=
if "%CPU%" == "AMD64" set BUFFEROVERFLOWLIB=bufferoverflowU.lib

if "%BITWIDTH%" == "32onWin64" set LIB=%DB2PATH%\lib\Win32;%LIB%

if "%1" == "" goto error
if "%2" == "" goto error
if "%3" == "" goto error

rem Precompile and bind the program files
call embprep %1  %2 %4 %5
call embprep %11 %2 %4 %5
call embprep %12 %3 %6 %7

rem  Compile the program files
if exist "%1.cxx" goto cpp
%BLDCOMP% -Zi -Od -c -W2 -DWIN32 %1.c %11.c %12.c utilemb.c
goto link
:cpp
%BLDCOMP% -Zi -Od -c -W2 -DWIN32 %1.cxx %11.cxx %12.cxx utilemb.cxx

rem Link the program.
:link
link -debug:full -debugtype:cv -out:%1.exe %1.obj %11.obj %12.obj utilemb.obj db2api.lib %BUFFEROVERFLOWLIB%

goto exit
:error
echo Usage: bldmc prog_name db_alias1 db_alias2 [ uid1 pwd1 uid2 pwd2 ]
:exit
@echo on