@echo off

REM $Id: PreLink.bat 5192 2008-03-26 14:50:08Z kimmov $

set info=echo *

REM _ACP_ATLPROV was introduced in VC7. If not set, assume VC6.
REM _MSDEV_BLD_ENV_ was removed in VC8. Don't care about it if _ACP_ATLPROV is set.

if "%_ACP_ATLPROV%" == "" goto _MSDEV_BLD_ENV_(%_MSDEV_BLD_ENV_%)
set msdev=rem
set devenv=devenv
goto Configure

:_MSDEV_BLD_ENV_(1)
set msdev=msdev
set devenv=rem
goto Configure

:_MSDEV_BLD_ENV_()
echo Merge.dsp/Merge.vcproj pre-link script
echo Not intended for direct invocation through user interface
echo Pre-link command line: PreLink.bat $(IntDir) $(TargetPath)
pause
exit

:Configure
%info% Configure

cd
REM Enable echo lines below if you need to debug this script
REM echo %0
REM echo $(IntDir) = %1
REM echo $(TargetPath) = %2
del $(TargetPath)

REM Create build directories
mkdir ..\Build\expat
mkdir ..\Build\pcre

REM Configure PCRE
cd %2\..\..\..\Externals\pcre\config_pcre
nmake /f "configure.mak"
goto %1

:.\..\BuildTmp\MergeDebug
:".\..\BuildTmp\MergeDebug"
%info% ANSI/Debug
goto Debug

:.\..\BuildTmp\MergeUnicodeDebug
:".\..\BuildTmp\MergeUnicodeDebug"
%info% UNICODE/Debug
goto Debug

:.\..\BuildTmp\MergeRelease
:".\..\BuildTmp\MergeRelease"
%info% ANSI/Release
goto Release

:.\..\BuildTmp\MergeUnicodeRelease
:".\..\BuildTmp\MergeUnicodeRelease"
%info% UNICODE/Release
goto Release

:Debug
%info% Debug

REM Build expat
cd %2\..\..\..\Externals\expat\lib
%msdev% "expat.dsp" /make "expat - Win32 Debug"
%devenv% "expat_vc71.vcproj" /build "Debug"
%devenv% "expat_vc8.vcproj" /build "Debug"
cd %2\..\..\expat
copy lib\debug\libexpat.dll %2\..\

REM Build SCEW
cd %2\..\..\..\Externals\scew\win32
%msdev% "scew.dsp" /make "scew - Win32 Debug"
%devenv% "scew_vc71.vcproj" /build "Debug"
%devenv% "scew_vc8.vcproj" /build "Debug"

REM Build PCRE
cd %2\..\..\..\Externals\pcre\dll_pcre
%msdev% "pcre.dsp" /make "pcre - Win32 Debug"
%devenv% "pcre_vc71.vcproj" /build "Debug"
%devenv% "pcre_vc8.vcproj" /build "Debug"
cd %2\..\..\pcre
copy bin\debug\pcre.dll %2\..\
goto Common

:Release
%info% Release

REM Build expat
cd %2\..\..\..\Externals\expat\lib
%msdev% "expat.dsp" /make "expat - Win32 Release"
%devenv% "expat_vc71.vcproj" /build "Release"
%devenv% "expat_vc8.vcproj" /build "Release"
cd %2\..\..\expat
copy lib\release\libexpat.dll %2\..\


REM Build SCEW
cd %2\..\..\..\Externals\scew\win32
%msdev% "scew.dsp" /make "scew - Win32 Release"
%devenv% "scew_vc71.vcproj" /build "Release"
%devenv% "scew_vc8.vcproj" /build "Release"

REM Build PCRE
cd %2\..\..\..\Externals\pcre\dll_pcre
%msdev% "pcre.dsp" /make "pcre - Win32 Release"
%devenv% "pcre_vc71.vcproj" /build "Release"
%devenv% "pcre_vc8.vcproj" /build "Release"
cd %2\..\..\pcre
copy bin\release\pcre.dll %2\..\
goto Common

:Common
%info% Common
