@echo off
pushd "%CD%"
CD /D "%~dp0"
set GSDLLANG=en
set extdesc="the ImageMagick extension"

if "%OS%" == "Windows_NT" goto WinNT
if "%OS%" == "" goto Win95
if "%GSDLLANG%" == "en" echo Setup failed - your PATH has not been set
if "%GSDLLANG%" == "es" echo No se pudo realizar la configuraci˘n - no se ha establecido la RUTA.
if "%GSDLLANG%" == "fr" echo Ech‚c de l'installation - votre variable PATH n'a pas ‚t‚ ajust‚e
if "%GSDLLANG%" == "ru" echo “áâ ­®˘Ş  ­Ą ă¤ « áě - Ź“’ś ­Ą ˇë« ăáâ ­®˘«Ą­
goto End

:WinNT
set GEXTIMAGEMAGICK=%CD%
set GEXTIMAGEMAGICK_INSTALLED=%GEXTIMAGEMAGICK%\windows

set MAGICK_HOME=%GEXTIMAGEMAGICK_INSTALLED%
set PATH=%GEXTIMAGEMAGICK_INSTALLED%\bin;%PATH%
set GS_CP_SET=yes
goto Success

:Win95
if "%1" == "SetEnv" goto Win95Env
REM We'll invoke a second copy of the command processor to make
REM sure there's enough environment space
COMMAND /E:2048 /K %0 SetEnv
goto End

:Win95Env
set GEXTIMAGEMAGICK=%CD%
set PATH="%GEXTIMAGEMAGICK_INSTALLED%\bin";"%PATH%"
set GS_CP_SET=yes
goto Success

:Success

set fulldir=%~dp0

:: strip off everything up to (and including) ext dir
set extdir=%fulldir:*ext\=%

:: remove trailing slash
set extdir=%extdir:\=%


if "x%GSDLEXTS%" == "x" (
  set GSDLEXTS=%extdir%
) else (
  set GSDLEXTS=%GSDLEXTS%:%extdir%
)

echo +Your environment is now setup for %extdesc%

:End

popd