@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 SetupC06
computil SetupD06
if exist setenv.bat call setenv.bat

if (%NDC06%)==() if (%NDD06%)==() goto enderror
if (%NDC06%)==() SET NDC06=%NDD06%
if (%NDWINSYS%)==() goto enderror

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

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

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

%NDC06%\bin\dcc32.exe Indy60.dpk /M /H /W /JPHN -$d-l-n+p+r-s-t-w-y- %2 %3 %4
if errorlevel 1 goto enderror
%NDC06%\bin\dcc32.exe IdDummyUnit.pas /LIndy60.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

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

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

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

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

del Indy60.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

