@echo off
rem
rem $CoreSDI: build.bat.sed,v 1.5 2001/12/26 23:10:28 claudio Exp $
rem
rem Copyright (c) 2000, 2001, Core SDI S.A., Argentina
rem All rights reserved
rem 
rem Redistribution and use in source and binary forms, with or without
rem modification, are permitted provided that the following conditions
rem are met:
rem 
rem 1. Redistributions of source code must retain the above copyright
rem    notice, this list of conditions and the following disclaimer.
rem 2. Redistributions in binary form must reproduce the above copyright
rem    notice, this list of conditions and the following disclaimer in the
rem    documentation and/or other materials provided with the distribution.
rem 3. Neither name of the Core SDI S.A. nor the names of its contributors
rem    may be used to endorse or promote products derived from this software
rem    without specific prior written permission.
rem
rem THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
rem IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
rem OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
rem IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
rem INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
rem NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
rem THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

rem
rem Audit binary package builder for win32
rem

set VERSION=AUDIT_VERSION
set RELEASE=audit-v%VERSION%
set TEMPDIR=%TEMP%
set OUTDIR=%TEMPDIR%\%RELEASE%
set LOGFILE=%TEMPDIR%\%RELEASE%-build.log
set ZIP=zip
set PKGDIR=%1
if "x%PKGDIR%" == "x" set PKGDIR=.
if not exist %PKGDIR% mkdir %PKGDIR%


rem
rem XXX InstallShield will be used in near future
rem
rem set PKGBUILDER="\Program Files\InstallShield\Developer\System\ISCmdBld.exe"


rem
rem External libraries
rem
set OPENSSL_LIBDIR=%HOME%\openssl\openssl-0.9.6a\out32dll\Release
set Z_LIBDIR=%HOME%\zlib


rem
rem MSVC Environment
rem
call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
set CC=msdev

if not exist %UTDIR% goto create_buildir
rmdir %OUTDIR% /s /q 

:create_buildir
mkdir %OUTDIR%


rem
rem Internal variables
rem
set PACKAGE_PRJ=audit.ism
set OPENSSL_FILES=%OPENSSL_LIBDIR%\libeay32.dll
set ZLIB_FILES=%Z_LIBDIR%\zlib.dll
set CLIENT_NAME=audit_client
set SERVER_NAME=audit_server
set CLIENT_WORKSPACE=%CLIENT_NAME%.dsw
set SERVER_WORKSPACE=%SERVER_NAME%.dsw


rem
rem Compile client
rem
echo Compiling Audit Clients...
%CC% %CLIENT_WORKSPACE% /make "%CLIENT_NAME% - release" /rebuild >> %LOGFILE%
if ERRORLEVEL 0 goto compile_server
echo Clients compilation failed. Check the %LOGFILE% logfile.
goto exit


rem
rem Compile server
rem XXX port server to NT
rem
:compile_server
rem echo Compiling Audit Server...
rem %CC% %SERVER_WORKSPACE% /make "%SERVER_NAME% - release" /rebuild >> %LOGFILE%
rem if %ERRORLEVEL% equ 0 goto create_package
rem echo Server compilation failed. Check %LOGFILE% logfile.
rem goto exit


rem
rem Create binary package
rem
:create_package
echo Copying Binary Files into %OUTDIR%...
copy %OPENSSL_FILES% %OUTDIR% >> %LOGFILE%
copy %ZLIB_FILES% %OUTDIR% >> %LOGFILE%
copy .\src\audit\Release\audit.exe %OUTDIR% >> %LOGFILE%
copy .\src\modules\auth\raw\Release\auth_raw.dll %OUTDIR% >> %LOGFILE%
copy .\src\modules\auth\srp\Release\auth_srp.dll %OUTDIR% >> %LOGFILE%
copy .\README %OUTDIR% >> %LOGFILE%
copy .\RELEASE %OUTDIR% >> %LOGFILE%
copy .\COPYING %OUTDIR% >> %LOGFILE%
%ZIP% -r "%OUTDIR%"
mv zip.zip "%PKGDIR%\%RELEASE%.zip"
rmdir %OUTDIR% /s /q 

echo Audit binary package created at %PKGDIR%\%RELEASE%.zip


rem XXX InstallShield in near future
rem %PKGBUILDER% -p %BUILDIR%\%PACKAGE_PRJ% -r %RELEASE% -c COMP -e y >> %LOGFILE%
rem %PKGBUILDER% -p %PACKAGE_PRJ% -r %RELEASE% -c COMP -e y >> %LOGFILE%
rem if ERRORLEVEL equ 0 goto build_ok
rem echo Build failed. Check InstallShield logfile.
rem goto exit
rem :build_ok
rem copy "audit\Product Configuration 1\%RELEASE%\DiskImages\Disk1\setup.exe" .\audit.exe >> %LOGFILE%
rem echo Audit Binary Package has been created as AUDIT.EXE.


:exit
