
REM %NDC2006%

@echo off

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 SetupC2006
if exist setenv.bat call setenv.bat
if not exist ..\C2006\*.* md ..\C2006 >nul
if exist ..\C2006\*.* call clean.bat ..\C2006\

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

CD System
ECHO ****************
ECHO  Compile System 
ECHO ****************
%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z IndySystem100.dpk -$d-l-
if errorlevel 1 goto enderror

%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z /JPHN IndySystem100.dpk -$d-l-
REM ***************************************************
REM Create .LIB file
REM ***************************************************
echo Creating IndySystem100.LIB file, please wait...
..\LspFix IndySystem100.lsp
%NDC2006%\bin\tlib.exe IndySystem100.lib /P32 @IndySystem100.lsp
Move *.lib ..\..\C2006 >> nul
Move *.hpp ..\..\C2006 >> nul
Move id*.obj ..\..\C2006 >> nul
Move /Y IndySystem100.bpl ..\..\C2006 >> nul
Move /Y IndySystem100.bpi ..\..\C2006 >> nul
Move *.dcp ..\..\C2006 >> nul
if exist ..\C2006\IndySystem100.bak del ..\C2006\IndySystem100.bak >nul

CD ..
CD Core
ECHO **************
ECHO  Compile Core    
ECHO **************
%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z IndyCore100.dpk -$d-l-
if errorlevel 1 goto enderror

%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z /JPHN IndyCore100.dpk -$d-l-
REM ***************************************************
REM Create .LIB file
REM ***************************************************
echo Creating IndyCore100.LIB file, please wait...
..\LspFix IndyCore100.lsp
%NDC2006%\bin\tlib.exe IndyCore100.lib /P32 @IndyCore100.lsp
Move *.lib ..\..\C2006 >> nul
Move *.hpp ..\..\C2006 >> nul
Move id*.obj ..\..\C2006 >> nul
Move /Y IndyCore100.bpl ..\..\C2006 >> nul
Move /Y IndyCore100.bpi ..\..\C2006 >> nul
Move *.dcp ..\..\C2006 >> nul
if exist ..\C2006\IndyCore100.bak del ..\C2006\IndyCore100.bak >nul


%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z dclIndyCore100.dpk -$d-l-
if errorlevel 1 goto enderror

%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z /JPHN dclIndyCore100.dpk -$d-l-
REM ***************************************************
REM Create .LIB file
REM ***************************************************
echo Creating dclIndyCore100.LIB file, please wait...
..\LspFix dclIndyCore100.lsp
%NDC2006%\bin\tlib.exe dclIndyCore100.lib /P32 @dclIndyCore100.lsp
Move *.lib ..\..\C2006 >> nul
Move *.hpp ..\..\C2006 >> nul
Move id*.obj ..\..\C2006 >> nul
Move /Y dclIndyCore100.bpl ..\..\C2006 >> nul
Move /Y dclIndyCore100.bpi ..\..\C2006 >> nul
Move *.dcp ..\..\C2006 >> nul
if exist ..\C2006\dclIndyCore100.bak del ..\C2006\dclIndyCore100.bak >nul

CD ..
ECHO *******************
ECHO  Compile Protocols
ECHO *******************
CD Protocols
ECHO ************************
ECHO  IdCompressionIntercept
ECHO ************************
%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z IdCompressionIntercept.pas -$d-l-
if errorlevel 1 goto enderror
%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z /JPHN IdCompressionIntercept.pas -$d-l-
ECHO *************************
ECHO  Compile IndyProtocols60  
ECHO *************************
%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z IndyProtocols100.dpk -$d-l-
if errorlevel 1 goto enderror
%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z /JPHN IndyProtocols100.dpk -$d-l-

REM ***************************************************
REM Create .LIB file
REM ***************************************************
echo Creating IndyProtocols100.LIB file, please wait...
..\LspFix IndyProtocols100.lsp
%NDC2006%\bin\tlib.exe IndyProtocols100.lib /P32 @IndyProtocols100.lsp
Move *.lib ..\..\C2006 >> nul
Move *.hpp ..\..\C2006 >> nul
move id*.obj ..\..\C2006 >> nul
Move /Y IndyProtocols100.bpl ..\..\C2006 >> nul
Move /Y IndyProtocols100.bpi ..\..\C2006 >> nul
Move *.dcp ..\..\C2006 >> nul
if exist ..\C2006\IndyProtocols100.bak del ..\C2006\IndyProtocols100.bak >nul

ECHO ****************************
ECHO  Compile dclIndyProtocols60 
ECHO ****************************
%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z dclIndyProtocols100.dpk -$d-l-
if errorlevel 1 goto enderror

%NDC2006%\Bin\dcc32.exe -B -M -DBCB -N..\..\C2006 -U..\..\C2006 -H -W -Z /JPHN dclIndyProtocols100.dpk -$d-l-
REM ***************************************************
REM Create .LIB file
REM ***************************************************
echo Creating dclIndyProtocols100.LIB file, please wait...
..\LspFix dclIndyProtocols100.lsp
%NDC2006%\bin\tlib.exe dclIndyProtocols100.lib /P32 @dclIndyProtocols100.lsp
Move *.lib ..\..\C2006 >> nul
Move *.hpp ..\..\C2006 >> nul
Move id*.obj ..\..\C2006 >> nul
Move /Y dclIndyProtocols100.bpl ..\..\C2006 >> nul
Move /Y dclIndyProtocols100.bpi ..\..\C2006 >> nul
Move *.dcp ..\..\C2006 >> nul
if exist ..\C2006\dclIndyProtocols100.bak del ..\C2006\dclIndyProtocols100.bak >nul

CD ..
CD ..
ECHO.
goto ok
:ok
ECHO Adding compile_ok file
if exist compile_fail del compile_fail
ECHO Compile_OK > compile_ok
goto end
:enderror
CD ..
CD ..
ECHO Compile_Failed > compile_fail
del compile_run >> nul
ECHO ! Error occured 
:end
del compile_run >> nul

goto endok
:enderror
call clean
echo Error!
:endok
