@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 SetupD07
if exist setenv.bat call setenv.bat

if (%NDD07%)==() goto enderror
if (%NDWINSYS%)==() goto enderror

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

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

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

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

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

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

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

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

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

