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

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

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

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

cd ..\V10
REM ***************************************************
REM Compile Runtime Package Indy100
REM ***************************************************
REM IdCompressionIntercept.pas has to be compiled separately because of a DCC32 bug. The bug also appears when doing a full build.
%NDD10%\bin\dcc32.exe IdCompressionIntercept.pas /M /H /W /JPHN -$d-l-n+p+r-s-t-w-y- %2 %3 %4

%NDD10%\bin\dcc32.exe Indy100.dpk /M /H /W /JPHN -$d-l-n+p+r-s-t-w-y- %2 %3 %4
if errorlevel 1 goto enderror

%NDD10%\bin\dcc32.exe IdDummyUnit.pas /LIndy100.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

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

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

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

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

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

