echo off

rem This batch file prepares a DOS shell for use with Hitachi compiler tools.

echo %0: Setting environment variables..

rem Set the location of the Katana installation.
rem Default: C:\Katana

if not !%DCSDK_ROOT%==%DCSDK_ROOT%! goto katanarootalreadyset
SET DCSDK_ROOT=i:\soep8
:katanarootalreadyset

rem if !%DCSDK_ROOT%==%DCSDK_ROOT%! goto error_nokatanaroot
rem Check for the existence of a compatible shell.  At this time, only
rem Microsoft-designed COMMAND.COM is acceptable.

SET KATANA_ROOT=%DCSDK_ROOT%\SHINOBI

ver | find "Windows"
if errorlevel 1 goto error_notcompatibleshell

rem Add gnu make and the Hitachi compiler tools to the current path.

SET PATH=%PATH%;%DCSDK_ROOT%\UTILS\DEV\MAKE;%DCSDK_ROOT%\UTILS\DEV\SHC

rem Verify the existence of gnu make.

gmake -v > chk_2397.tmp
if not exist chk_2397.tmp goto error_nonmake
del chk_2397.tmp

rem Set include and library directories used by Hitachi compiler tools.
rem Edit these lines to change the default installation.
rem Default: SET SHC_LIB=C:\Katana\Utl\Dev\Hitachi
rem Default: SET SHC_INC=C:\Katana\Include

SET SHC_LIB=%DCSDK_ROOT%\UTILS\DEV\SHC
SET SHC_INC=%DCSDK_ROOT%\SHINOBI\INCLUDE
SET SHCPP_LIB=%SHC_LIB%
SET SHCPP_INC=%SHC_INC%

rem Verify Hitachi tool paths.

if !%SHC_LIB%==%SHC_LIB%! goto error_shcpathsnotset
if !%SHC_INC%==%SHC_INC%! goto error_shcpathsnotset
if !%SHCPP_LIB%==%SHCPP_LIB%! goto error_shcpathsnotset
if !%SHCPP_INC%==%SHCPP_INC%! goto error_shcpathsnotset
if not exist %SHC_LIB%\nul goto error_shcpathsnotset
if not exist %SHC_INC%\nul goto error_shcpathsnotset
if not exist %SHCPP_LIB%\nul goto error_shcpathsnotset
if not exist %SHCPP_INC%\nul goto error_shcpathsnotset

rem Set location of temporary files created during compilation.
rem These files (.tmp) may be left behind when a compile is interrupted.
rem Default:  SET SHC_TMP=.

SET SHC_TMP=.
SET SHCPP_TMP=%SHC_TMP%

rem Set default library for Hitachi C/C++.
rem Default: SET HLNK_LIBRARY1=C:\Katana\Lib\sh4nlfzz.lib

SET HLNK_LIBRARY1=%KATANA_ROOT%\LIB\SH4NLFZZ.LIB

rem Verify the existence of HLNK_LIBRARY1

if !%HLNK_LIBRARY1%==%HLNK_LIBRARY1%! goto error_hlnknotset
if not exist %HLNK_LIBRARY1% goto error_hlnknotset

rem Verify the existence of the Hitachi tools.

shc > chk_2397.tmp
if not exist chk_2397.tmp goto error_cmd
del chk_2397.tmp

goto success

rem -------------------------------------------------------------------
rem ! Error handling
rem -------------------------------------------------------------------

:error_nokatanaroot
echo Error: The path specified by the KATANA_ROOT variable does not
echo exist.  Please edit SETPATHS.BAT.
goto done

:error_notcompatibleshell
echo Error: The COMMAND.COM shell is not compatible with SetPaths.
echo Please make COMMAND.COM your default shell and try again.
goto done

:error_nonmake
echo Error: Gnu MAKE could not be found on the default path.  Please
echo edit SETPATHS.BAT.
goto done

:error_cmd
echo Error: The Hitachi command line tools could not be found.
echo Please edit SETPATHS.BAT.
goto done

:error_shcpathsnotset
echo Error: Environmental variables required by the SH-C compiler could
echo not be determined, or do not point to valid directories.  Please
echo edit SETPATHS.BAT.
goto done

:error_hlnknotset
echo Error: Environmental variable HLNK_LIBRARY1 is required and
echo could not be determined, or target file does not exist.  Please
echo edit SETPATHS.BAT.
goto done

:success
echo.
echo Paths successfully set and verified.
:done

