@REM 20080913 - Remove OpenAL for MSVC9 compile, under Vista 32-bit - using OpenAL SDK
@REM 20080418 - Adjusted freeglut, and lpng1225 to libpng-1.2.26 - ready for MSVC9 compile, under Vista 32-bit
@set TEMPPNG=lpng1232
@REM set TEMPPNG=libpng-1.2.26
@REM 20080309 - Added PNG lpng1225 folder, for osgdb-png.dll building
@REM 20070804 - Exclude OpenThreads, 20070516 - Minor adjustments. 20070319 - EXCLUDED Producer ...
@REM Establish SOURCE *** CHANGE THIS TO SUIT YOUR DISK:FOLDER STRUCTURE ***
@REM =======================================================================
@set TEMP2=C:\FGCVS
@REM =======================================================================
@REM Establish DESTINATION from input ...
@set TEMP1=%1
@set TEMP3=xcopy /S /Q
@echo Set up a NEW flightgear folder called [%TEMP1%] ...
@echo Checking all sources from %TEMP2% ...
@REM Do a CHECK of what is available
@if NOT EXIST %TEMP2%\FlightGear\source\. goto ERR3
@if NOT EXIST %TEMP2%\FlightGear\source\src\. goto ERR3B
@if NOT EXIST %TEMP2%\freeglut\. goto ERR4
@if NOT EXIST %TEMP2%\freeglut\include\GL\freeglut.h goto ERR4B
@REM if NOT EXIST %TEMP2%\OpenAL\. goto ERR5
@if NOT EXIST %TEMP2%\OpenSceneGraph\. goto ERR6
@if NOT EXIST %TEMP2%\OpenSceneGraph\include\osg\. goto ERR6B
@REM if NOT EXIST %TEMP2%\OpenThreads\. goto ERR7
@if NOT EXIST %TEMP2%\PLIB\. goto ERR8
@if NOT EXIST %TEMP2%\PLIB\src\. goto ERR8B
@if NOT EXIST %TEMP2%\pthreads\. goto ERR10
@if NOT EXIST %TEMP2%\pthreads\pthread.h goto ERR10B
@if NOT EXIST %TEMP2%\SimGear\source\. goto ERR11
@if NOT EXIST %TEMP2%\SimGear\source\simgear\. goto ERR11B
@if NOT EXIST %TEMP2%\zlib-1.2.3\. goto ERR12
@if NOT EXIST %TEMP2%\zlib-1.2.3\zlib.h goto ERR12B
@if NOT EXIST %TEMP2%\%TEMPPNG%\projects\. goto ERR13
@if NOT EXIST %TEMP2%\%TEMPPNG%\png.h goto ERR13B
@if NOT EXIST %TEMP2%\FlightGear\data\. goto ERR2
:DNFGDATA
@if NOT EXIST %TEMP2%\freealut-1.1.0-src\. goto ERR14
@if NOT EXIST %TEMP2%\freealut-1.1.0-src\include\AL\alut.h goto ERR14B

@echo ALL REQUIRED SOURCES appear to have been found ... GOOD WORK ;=))
@echo HAVE YOU UPDATED ALL THESE SOURCES?

@REM NO INPUT ... give HELP
@if "%TEMP1%." == "." goto HELP
@REM NO OVERWRITE OF AN EXISTING FOLDER
@if EXIST %TEMP1%\. goto NOWAY

:DOIT
@echo *** Is this folder [%TEMP1%] correct? *** ... Ctrl+C to abort ...
@pause

@set TEMPST=%TIME%
md %TEMP1%
cd %TEMP1%
@echo Making the FOLDERS ...
@echo Copying sources ... this can take some time ...
md bin
@cd bin
@REM md OpenAL
@cd ..
md fgfs
md FlightGear
cd FlightGear
%TEMP3% %TEMP2%\FlightGear\source\*.* .
cd ..
md freeglut
cd freeglut
%TEMP3% %TEMP2%\freeglut\*.* .
cd ..
@REM md OpenAL
@REM cd OpenAL
@REM %TEMP3% %TEMP2%\OpenAL\*.* .
@REM cd ..
md OpenSceneGraph
cd OpenSceneGraph
%TEMP3% %TEMP2%\OpenSceneGraph\*.* .
cd ..
@REM md OpenThreads
@REM cd OpenThreads
@REM %TEMP3% %TEMP2%\OpenThreads\*.* .
@REM cd ..
md PLIB
cd PLIB
%TEMP3% %TEMP2%\PLIB\*.* .
cd ..
md pthreads
cd pthreads
%TEMP3% %TEMP2%\pthreads\*.* .
cd ..
md SimGear
cd SimGear
%TEMP3% %TEMP2%\SimGear\source\*.* .
cd ..
md zlib-1.2.3
cd zlib-1.2.3
%TEMP3% %TEMP2%\zlib-1.2.3\*.* .
cd ..
@REM This may not be the current version name, but otherwise must change the solution file - UGH
md lpng
cd lpng
%TEMP3% %TEMP2%\%TEMPPNG%\*.* .
cd ..
@REM and alut
md alut
cd alut
%TEMP3% %TEMP2%\freealut-1.1.0-src\*.* .
cd ..
 
@echo %TEMPST% %TIME%
@echo Done ... this folder is ready for extraction of vc?sln??.zip (or vc?dsp??.zip) ...
@if NOT EXIST %TEMP2%\FlightGear\data\. goto DONEDATA
@echo This NEXT step requires over 1.5GB ... and several minutes ...
@echo *** INCLUDE FLightGear data? *** Ctrl+C to exit ...
@pause

md data
cd data
%TEMP3% %TEMP2%\FlightGear\data\*.* .
cd ..
:DONEDATA
@echo All done ... this folder [%TEMP1%] is ready for extraction of vc?sln??.zip ...
@goto END

:NOWAY
@echo Appear %TEMP1% already exists ... must be a NEW folder name ...
@goto DONE

:HELP
@echo List of EXISTING folders ...
dir /ad /od
@echo If data included, after the build of both Release and Debug, will 
@echo consume about 3-6GB ... data is about 1.5GB plus ... CHECK YOU HAVE THE SPACE!
@echo Must give the name of a new FOLDER to set up ...
@echo but NOT one of the above folders, if any ...
@echo Must give the name of the NEW FOLDER to copy sources to ...
@goto DONE

:Err2
@echo WARNING: Missing %TEMP2%\FlightGear\data\.
@echo but this is NOT treated as FATAL ERROR ...
@goto DNFGDATA

:Err3
@echo ERROR: Missing %TEMP2%\FlightGear\source\.
@goto GOTERR
:Err3B
@echo ERROR: Missing %TEMP2%\FlightGear\source\src\.
@goto GOTERR

:Err4
@echo ERROR: Missing %TEMP2%\freeglut\.
@goto GOTERR
:Err4B
@echo ERROR: Missing %TEMP2%\freeglut\include\GL\freeglut.h
@goto GOTERR

@REM :Err5
@REM echo ERROR: Missing %TEMP2%\OpenAL\.
@REM goto GOTERR

:Err6
@echo ERROR: Missing %TEMP2%\OpenSceneGraph\.
@goto GOTERR
:Err6B
@echo ERROR: Missing %TEMP2%\OpenSceneGraph\include\osg\.
@goto GOTERR

@REM :Err7
@REM echo ERROR: Missing %TEMP2%\OpenThreads\.
@REM goto GOTERR

:Err8
@echo ERROR: Missing %TEMP2%\PLIB\.
@goto GOTERR
:Err8B
@echo ERROR: Missing %TEMP2%\PLIB\src\.
@goto GOTERR

:Err10
@echo ERROR: Missing %TEMP2%\pthreads\.
@goto GOTERR
:Err10B
@echo ERROR: Missing %TEMP2%\pthreads\pthread.h
@goto GOTERR

:Err11
@echo ERROR: Missing %TEMP2%\SimGear\source\.
@goto GOTERR
:Err11B
@echo ERROR: Missing %TEMP2%\SimGear\source\simgear\.
@goto GOTERR

:Err12
@echo ERROR: Missing %TEMP2%\zlib-1.2.3\. - Needed for OSG osgdb-png.dll, and for SG/FG ...
@goto GOTERR
:Err12B
@echo ERROR: Missing %TEMP2%\zlib-1.2.3\zlib.h - Needed for OSG osgdb-png.dll, and for SG/FG ...
@goto GOTERR

:Err13B
@echo ERROR: Missing %TEMP2%\%TEMPPNG%\png.h - Needed for OSG osgdb-png.dll ...
@goto Err13More
:Err13
@echo ERROR: Missing %TEMP2%\%TEMPPNG%\projects\. - Needed for OSG osgdb-png.dll ...
:Err13More
@echo Perhaps you are using a different PNG version than %TEMPPNG%, in which case adjust this batch,
@echo and fgfs.sln will also have to be adjusted. Or rename your PNG source
@echo folder to %TEMPPNG%, whatever the version ...
@goto GOTERR

:Err14
@echo ERROR: Missing %TEMP2%\freealut-1.1.0-src - Needed for alut.dll creation ...
@goto GOTERR
:Err14B
@echo ERROR: Missing %TEMP2%\freealut-1.1.0-src\include\AL\alut.h - Needed for alut.dll creation ...
@goto GOTERR

:GOTERR
@echo Check name, location carefully ...
@echo If you already have this source built, then you can
@echo adjust this BATCH file to exclude this folder.
@echo This will also require adjustment of the fgfs.sln file when loaded in
@echo MSVC, and may also require adjustment of UPB.BAT, update.mak, etc, if used ...
@goto DONE

:END
@echo Ran from %TEMPST% to %TIME% ...
:DONE
@echo From %TEMPST% to %TIME% > tempst.txt
