@echo off
cls

if (%1)==() goto test_command
if (%1)==(start) goto start
goto endok

:test_command
if (%COMSPEC%)==() goto no_command
%COMSPEC% /E:9216 /C %0 start %1 %2 %3
goto endok

:no_command
echo No Command Interpreter found
goto endok

:start
call clean.bat
computil SetupC05
computil SetupD05
if exist setenv.bat call setenv.bat

if (%NDC05%)==() if (%NDD05%)==() goto enderror
if (%NDC05%)==() SET NDC05=%NDD05%
if (%NDWINSYS%)==() goto enderror

if not exist ..\V05\*.* md ..\V05 >nul
if exist ..\V05\*.* call clean.bat ..\V05\

copy *.pas ..\V05 > nul
copy *.dpk ..\V05 > nul
copy *.obj ..\V05 > nul
copy *.inc ..\V05 > nul
copy *.res ..\V05 > nul
copy *.dcr ..\V05 > nul
copy *.rsp ..\V05 > nul

cd ..\V05
REM ***************************************************
REM Compile Runtime Package Indy50
REM ***************************************************
REM IdCompressionIntercept can never be built as part of a package.  It has to be compileed separately
REM due to a DCC32 bug.
%NDC05%\bin\dcc32.exe IdCompressionIntercept.pas /M /H /W /JPHN -$d-l-n+p+r-s-t-w-y- %2 %3 %4

%NDC05%\bin\dcc32.exe Indy50.dpk /M /H /W /JPHN -$d-l-n+p+r-s-t-w-y- %2 %3 %4
if errorlevel 1 goto enderror
%NDC05%\bin\dcc32.exe IdDummyUnit.pas /LIndy50.dcp /M /H /W /JPHN -$d-l-n+p+r-s-t-w-y- %2 %3 %4
if errorlevel 1 goto enderror
del IdDummyUnit.dcu >nul
del IdDummyUnit.hpp >nul
del IdDummyUnit.obj >nul

%NDC05%\bin\dcc32.exe Indy50.dpk /M /H /W -$d-l-n+p+r-s-t-w-y- %2 %3 %4
if errorlevel 1 goto enderror
copy Indy50.bpl %NDWINSYS% >nul
del Indy50.bpl > nul

REM ***************************************************
REM Create .LIB file
REM ***************************************************
echo Creating Indy50.LIB file, please wait...
if exist %NDC05%\bin\tlib.exe %NDC05%\bin\tlib.exe Indy50.lib /P32 @IndyWin32.rsp >nul
if exist ..\V05\Indy50.bak del ..\V05\Indy50.bak >nul

REM ***************************************************
REM Compile Design-time Package RPDT30
REM ***************************************************
%NDC05%\bin\dcc32.exe dclIndy50.dpk /H /W /N..\V05 /LIndy50.dcp -$d-l-n+p+r-s-t-w-y- %2 %3 %4
if errorlevel 1 goto enderror

REM ***************************************************
REM Clean-up
REM ***************************************************
del dclIndy50.dcu >nul
del dclIndy50.dcp >nul

del Indy50.dcu >nul
del *.pas > nul
del *.dpk > nul
del *.inc > nul
del *.res > nul
del *.dcr > nul
del *.rsp > nul
REM ***************************************************
REM Design-time only unit .DCU's are not needed.
REM ***************************************************
if exist IdAbout.dcu del IdAbout.dcu >nul
if exist IdDsnBaseCmpEdt.dcu del IdDsnBaseCmpEdt.dcu >nul
if exist IdDsnPropEdBinding.dcu del IdDsnPropEdBinding.dcu >nul
if exist IdDsnRegister.dcu del IdDsnRegister.dcu >nul
if exist IdRegister.dcu del IdRegister.dcu >nul

goto endok
:enderror
call clean
echo Error!
:endok
cd ..\Source

