Index: local/greenstone2/windows-64bit/devel64-in32mode.bat
===================================================================
--- local/greenstone2/windows-64bit/devel64-in32mode.bat	(revision 31424)
+++ local/greenstone2/windows-64bit/devel64-in32mode.bat	(revision 31426)
@@ -1,8 +1,11 @@
-:: This script is called devel.bat NOT setup.bat, because firstly, it is for compiling GS2
-:: and secondly, this script wipes out PATH and sets it from scratch. Running the toplevel GS2 setup.bat
-:: will invoke any setup.bat in this local folder, and if this script were called setup.bat it would wipe
-:: out the Greenstone PATH environment as adjusted by GS2 so we'd not be able to run any Greenstone scripts
-:: despite sourcing GS2's toplevel setup.bat. Hence this script is called devel.bat.
+@echo off
+echo.
+echo **
 
+:: There used to be a race condition when compiling apache httpd that caused GS2 compilation to fail.
+:: See the notes on compiling GS2 on 64 bit Win 7 at
+:: http://wiki.greenstone.org/doku.php?id=en:developer:compiling_apache&#compiling_the_apache-httpd_included_with_gs2_on_64_bit_windows_7
+:: Sam fixed this for the release-kit with http://trac.greenstone.org/changeset/22490
+:: while it's at last been fixed in the svn version with commit 31425 (building on flawed earlier attempts in commits 31421 and 31422).
 
 :: Get the strawberry perl we use for GS from http://trac.greenstone.org/browser/main/trunk/release-kits/shared/windows/perl.zip?rev=head
@@ -10,27 +13,68 @@
 
 set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55
+if not exist "%JAVA_HOME%" echo %JAVA_HOME% does not exist& goto done
 
-:: NOTE: we are indeed wiping out PATH and setting it from scratch. This follows what the releasekits do each night when generating GS2-caveat
-:: and that always seems to successfully compile apache-httpd in one go. So after setting PATH from scratch here, we only need to worry about
-:: race conditions affecting GS2 compiling (particularly apache-httpd) on recompile of GS2. In that case, just delete gs2-svn\apache-httpd\windows\error
-:: and retry recompilation with makegs2x64.bat, or just plain retry recompilation with that script.
+set PERL_HOME=C:\strawberry-perl32no64\perl
+if not exist "%PERL_HOME%" echo %PERL_HOME% does not exist& goto done
 
-set PATH=%JAVA_HOME%\bin;C:\strawberry-perl32no64\perl\bin;C:\Program Files\SlikSvn\bin;%PATH%
+set PATH=%JAVA_HOME%\bin;%PERL_HOME%\bin;C:\Program Files\SlikSvn\bin;%PATH%
 
-::set PATH=%JAVA_HOME%\bin;C:\strawberry-perl32no64\perl\bin;C:\Program Files\SlikSvn\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\putty;C:\Program Files (x86)\linuxtools
-::set PATH=%JAVA_HOME%\bin;C:\strawberry-perl32no64\perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
-:: REMOVING CMake from PATH:
-rem C:\Program Files (x86)\Java\jdk1.8.0_65\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Windows Performance Toolkit\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\nodejs\;C:\Program Files\SlikSvn\bin;C:\Program Files\Git\cmd;C:\Users\Anupama\AppData\Roaming\npm
-rem %PATH%
 
-:: Microsoft SDK is needed only if compiling GS2 with debugging on,
-:: but regular compiling (without debugging on) will also work with MS SDK environment:
-pushd "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin"
-call "SetEnv.Cmd"
-popd
+echo + Set JAVA_HOME=%JAVA_HOME% and updated PATH
+echo + Set PERL_PATH=%PERL_HOME% and updated PATH
 
-:: MS Visual Studio needed to compile GS2
-pushd "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\"
+
+:: Microsoft SDK no longer needed. Used to be needed only if compiling GS2 with debugging on,
+:: but regular compiling (without debugging on) will also work with MS SDK environment.
+rem set sdklocation=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin
+rem if not exist "%sdklocation%" echo %sdklocation% does not exist& goto done
+rem pushd "%sdklocation%"
+rem call "SetEnv.Cmd"
+rem popd
+
+
+
+:: Set up Visual MS Studio env  needed to compile GS2.
+:: Running VS in 64 bit mode doesn't work, need to run in 32 bit mode. 
+:: (It may be apache httpd that needs 32 bit mode to compile.)
+:: For now only VS9.0 (VS2008) works
+set vslocation=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools
+if not exist "%vslocation%" echo %vslocation% does not exist& goto done
+pushd "%vslocation%"
 call vsvars32.bat
 popd
 
+:done
+echo Leaving local/setup.bat
+echo ******************************
+echo.
+
+
+:: **********************************************************************************
+:: Porting further remarks and attempted code from older version of setup.bat file
+:: **********************************************************************************
+:: VS10 fails: Common Tools folder not found for VS10
+rem call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
+
+:: VS12 fails: Calling "vsvars32.bat" above produces the same error as calling
+:: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\vcvarsamd64_x86.bat
+:: (and possibly the same error as calling
+:: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat without passing "amd64" param)
+rem call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat"
+
+:: Error: https://groups.google.com/forum/#!topic/UniMRCP/Iybpn51UYnI
+:: http://msdn.microsoft.com/en-us/library/ff770576.aspx
+:: http://stackoverflow.com/questions/11544563/can-i-set-the-platform-toolset-from-the-command-line-when-building-with-vs2010s
+:: /p:PlatformToolset=v100
+
+
+:: If using SetEnv.cmd to set up MS SDK env (no longer needed even for compiling GS2 with debug):
+
+::call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"
+:: Run with /? to see what options it takes (/x86, /x64, /ia64, /vista, /xp, /win7 and more)
+
+::set sdklocation=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin
+::if not exist "%sdklocation%" echo %sdklocation% does not exist& goto done
+::pushd "%sdklocation%"
+::call SetEnv.cmd /x64
+::popd
