@echo off
if not "%1" == "" goto ok

echo Usage: rsxntenv [drive]  or rsxntenv remove
echo    Where [drive] is C,D,...
echo    rsxntenv remove will clean up environment
goto end

:ok
if not "%1" == "remove" goto setenv
SET PATH=%PATH_OLD%
SET PATH_OLD=
SET C_INCLUDE_PATH=
SET CPLUS_INCLUDE_PATH=
SET LIBRARY_PATH=
goto end

:setenv
set PATH_OLD=%PATH%
set PATH=%PATH%;%1:\RSXNT\BIN

if not "%C_INCLUDE_PATH%" == "" goto haveinc
if not exist %1:\EMX\INCLUDE goto noemx
set C_INCLUDE_PATH=%1:\EMX\INCLUDE
:haveinc
set C_INCLUDE_PATH=%1:\RSXNT\INCLUDE;%1:\RSXNT\INCLUDE\WIN32;%C_INCLUDE_PATH%

if not "%CPLUS_INCLUDE_PATH%" == "" goto haveinc
if not exist %1:\EMX\INCLUDE\CPP goto noemx
set CPLUS_INCLUDE_PATH=%1:\EMX\INCLUDE\CPP;%1:\EMX\INCLUDE
:haveinc
set CPLUS_INCLUDE_PATH=%1:\RSXNT\INCLUDE;%1:\RSXNT\INCLUDE\WIN32;%CPLUS_INCLUDE_PATH%

if not "%LIBRARY_PATH%" == "" goto havelib
if not exist %1:\EMX\LIB\CRT0.O goto noemx
set LIBRARY_PATH=%1:\EMX\LIB
:havelib
set LIBRARY_PATH=%1:\RSXNT\LIB;%LIBRARY_PATH%

echo Setting PATH to %PATH%
echo Setting C_INCLUDE_PATH to %C_INCLUDE_PATH%
echo Setting CPLUS_INCLUDE_PATH to %CPLUS_INCLUDE_PATH%
echo Setting LIBRARY_PATH to %LIBRARY_PATH%
goto end

:noemx
echo Kann EMX nicht finden (%1:\EMX)
goto end

:end
