@echo off
rem -------------------------------------------------------------------------
rem
rem Environment Variable Prerequisites:
rem
rem
rem   SPCL_HOME  (Required!) 
rem
rem   CLASSPATH    (Required!) 
rem
rem   JAVA_HOME    (Required!) Must point at your Java Development Kit installation.
rem
rem -------------------------------------------------------------------------
rem Michael E. Locasto

rem save a copy of current java_home and other vars

set _JAVA_HOME=%JAVA_HOME%
set _SPCL_HOME=%SPCL_HOME%
set _CLASSPATH=%CLASSPATH%


rem setup our needed environment variables and the run-time classpath

set SPCL_HOME=c:\usr\projects\spcl\spcl-0.1
set JAVA_HOME=c:\opt\java\sdk\jdk1.4.1

rem if you add another jar that you need, make sure to add another line to this section
set CLASSPATH=%SPCL_HOME%\lib\data.jar
set CLASSPATH=%CLASSPATH%;%SPCL_HOME%\lib\polc.jar
set CLASSPATH=%CLASSPATH%;%SPCL_HOME%\lib\pole.jar
set CLASSPATH=%CLASSPATH%;%SPCL_HOME%\lib\core.jar

if not "%JAVA_HOME%" == "" goto gotJavaHome
echo You must set JAVA_HOME to point at your Java Development Kit installation
goto cleanup
:gotJavaHome

if not "%SPCL_HOME%" == "" goto gotAPPHome
echo You must set SPCL_HOME to point at your application installation
goto cleanup
:gotAPPHome

if "%1" == "" goto doUsage
if "%1" == "help" goto doUsage
if "%1" == "-help" goto doUsage

goto compile

:doUsage
echo ------------------------------------------------------------------
echo NOTICE: Use at your own risk.
echo ------------------------------------------------------------------
echo Usage...  [-lex | -parse] [filename].spcl
goto cleanup


:compile
%JAVA_HOME%\bin\java -client -classpath %CLASSPATH% -Dspcl.home="%SPCL_HOME%" spcl.compiler.SPCLCompiler %1 %2 %3 %4 %5 %6 %7 %8 %9
goto cleanup


rem ------ cleanup -----------------------------------------------------------------------
:cleanup
rem cd %SPCL_HOME%\bin

set CLASSPATH=%_CLASSPATH%
set _CLASSPATH=
set SPCL_HOME=%_SPCL_HOME%
set _SPCL_HOME=
set JAVA_HOME=%_JAVA_HOME%
set _JAVA_HOME=
:finish