echo off

rem This batch file prepares a DOS shell for use with Hitachi compiler tools.
rem Microsoft Dev. Studio's NMAKE utility is required to build the examples.

echo %0: Setting environment variables..

rem Add NMAKE and the Hitachi compiler tools to the current path.
rem Default: PATH=%PATH%;"C:\Program Files\DevStudio\VC\Bin";"C:\Program Files\DevStudio\SharedIDE\Bin";"C:\Katana\Utl\Dev\Hitachi"

SET PATH=%PATH%

rem Verify the existence of NMAKE.

nmake /? > 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\lib\libc\include

SET SHC_LIB=
SET SHC_INC=
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\Libc\Lib\sh4nlfzz.lib

SET HLNK_LIBRARY1=

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_nonmake
echo Error: NMAKE 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

