@ECHO OFF

if (%1)==() goto WORK
if (%1)==(r) goto  REBUILD
if (%1)==(R) goto  REBUILD
if (%1)==(b) goto  DEBUG
if (%1)==(B) goto  DEBUG
if (%1)==(RB) goto REBUILDDEBUG
if (%1)==(BR) goto REBUILDDEBUG
if (%1)==(rb) goto REBUILDDEBUG
if (%1)==(br) goto REBUILDDEBUG
if (%1)==(d) goto DEMO
if (%1)==(D) goto DEMO

echo Параметры командной строки:
echo r - пересборка без отладки в BIN\
echo b - сборка с отладкой в BINB\
echo rb - пересборка с отладкой в BINB\
echo d - пересборка DEMO в BIN\
echo без параметра - сборка без отладки в BIN\
goto EXIT

:WORK
set CFLAGS=-c -O2 -tW -tWM -d -a8 -OS -5 -6 -DHB_NO_TRACE -DHB_NO_PROFILE
set OBJ_DIR=%WORK_OBJ_DIR%
set LIB_NAME=%WORK_LIB%
set EXEPATH=..\%WORK_EXEPATH%
set BINPATH=%WORK_EXEPATH%
..\bcc5\bin\make -fh%PROJECT%.bc  >h%PROJECT%.log
goto M


:DEMO
set CFLAGS=-c -O2 -tW -tWM -d -a8 -OS -5 -6 -DHB_NO_TRACE -DHB_NO_PROFILE
set OBJ_DIR=%WORK_OBJ_DIR%D
set LIB_NAME=LIB\pll32D.lib
set EXEPATH=..\%WORK_EXEPATH%D
set BINPATH=%WORK_EXEPATH%D
set HFLAGS=%HFLAGS% -l -dDEMO -p
set HFLAGS1=%HFLAGS1% -l -dDEMO -p
..\bcc5\bin\make -fh%PROJECT%.bc -B >h%PROJECT%.log
goto M



:REBUILD
set CFLAGS=-c -O2 -tW -tWM -d -a8 -OS -5 -6 -DHB_NO_TRACE -DHB_NO_PROFILE
set OBJ_DIR=%WORK_OBJ_DIR%
set LIB_NAME=%WORK_LIB%
set EXEPATH=..\%WORK_EXEPATH%
set BINPATH=%WORK_EXEPATH%
@if exist %EXEPATH%\%PROJECT%.exe del %EXEPATH%\%PROJECT%.exe
..\bcc5\bin\make -fh%PROJECT%.bc -B >h%PROJECT%.log
goto M

:DEBUG
set OBJ_DIR=%DEBUG_OBJ_DIR%
set LIB_NAME=%DEBUG_LIB%
set EXEPATH=..\%DEBUG_EXEPATH%
set BINPATH=%DEBUG_EXEPATH%
set HFLAGS=%HFLAGS% -b -d_DEBUG -p
set HFLAGS1=%HFLAGS1% -b -d_DEBUG -p
..\bcc5\bin\make -fh%PROJECT%.bc >h%PROJECT%.log
goto M

:REBUILDDEBUG
set OBJ_DIR=%DEBUG_OBJ_DIR%
set LIB_NAME=%DEBUG_LIB%
set EXEPATH=..\%DEBUG_EXEPATH%
set BINPATH=%DEBUG_EXEPATH%
set HFLAGS=%HFLAGS% -b -d_DEBUG -p
set HFLAGS1=%HFLAGS1% -b -d_DEBUG -p
@if exist %EXEPATH%\%PROJECT%.exe del %EXEPATH%\%PROJECT%.exe
..\bcc5\bin\make -fh%PROJECT%.bc -B >h%PROJECT%.log
goto M

:M
if errorlevel 1 goto ERR
GOTO EXIT

:ERR
echo *** Ошибки см. в h%PROJECT%.log ***
if (%2)==() goto  EXIT
START NOTEPAD.exe h%PROJECT%.log
:EXIT