remtrace Compile C code of the libraries
remtrace "A tout seigneur tout honneur", let's start with the run-time
md %INSTALL_DIR\releases
md %INSTALL_DIR\releases\enterprise_version
md %INSTALL_DIR\releases\gpl_version

remtrace Compile the run-times
iff not defined WIN64 then
	remtrace Compile a run-time for MinGW
	cdd %EIFFEL_SRC\C
	call configure clean >>& %INSTALL_LOG
	call configure win32 g >>& %INSTALL_LOG
	cd %EIFFEL_SRC
	copy C\run-time\LIB\*.a %STUDIO_DIR\studio\spec\%ISE_PLATFORM\lib\mingw

	remtrace Compile a dynamic run-time for MinGW
	cdd %EIFFEL_SRC\C
	call configure clean >>& %INSTALL_LOG
	call configure win32 g dll >>& %INSTALL_LOG
	cd %EIFFEL_SRC
	copy C\run-time\LIB\*dll* %STUDIO_DIR\studio\spec\%ISE_PLATFORM\lib\mingw
else
	remtrace Compile a run-time for MinGW
	cdd %EIFFEL_SRC\C
	call configure clean >>& %INSTALL_LOG
	call configure win64 g >>& %INSTALL_LOG
	cd %EIFFEL_SRC
	copy C\run-time\LIB\*.a %STUDIO_DIR\studio\spec\%ISE_PLATFORM\lib\mingw

	remtrace Compile a dynamic run-time for MinGW
	cdd %EIFFEL_SRC\C
	call configure clean >>& %INSTALL_LOG
	call configure win64 g dll >>& %INSTALL_LOG
	cd %EIFFEL_SRC
	copy C\run-time\LIB\*dll* %STUDIO_DIR\studio\spec\%ISE_PLATFORM\lib\mingw
endiff

remtrace Copy the configuration file
iff not defined WIN64 then
	copy %EIFFEL_SRC\C\CONFIGS\windows-x86-mingw %STUDIO_DIR\studio\config\%ISE_PLATFORM\mingw\config.sh
else
	copy %EIFFEL_SRC\C\CONFIGS\windows-x86-64-mingw %STUDIO_DIR\studio\config\%ISE_PLATFORM\mingw\config.sh
endiff

remtrace Compile the run-time for Microsoft
espawn -u:VC140 "%COMSPEC% /c %INIT_DIR%\inc\make_runtimes.btm msc_vc140"
iff defined %ISE_C_COMPILER_VER% then
	espawn -u:%ISE_C_COMPILER_VER% "%COMSPEC% /c %INIT_DIR%\inc\make_runtimes.btm msc"
else
	echo MISSING ISE_C_COMPILER_VER !!!
endiff

remtrace Copy the header files
copy %EIFFEL_SRC\C\run-time\*.h %STUDIO_DIR\studio\spec\%ISE_PLATFORM\include
copy %EIFFEL_SRC\C\run-time\eif_stack.decl %STUDIO_DIR\studio\spec\%ISE_PLATFORM\include
copy %EIFFEL_SRC\C\run-time\eif_stack.interface %STUDIO_DIR\studio\spec\%ISE_PLATFORM\include
cd %EIFFEL_SRC

remtrace Copy the MSYS part
copy %EIFFEL_SRC\C\shell\bin\rt_converter.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin\
copy %EIFFEL_SRC\C\shell\bin\sed.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin\
copy %EIFFEL_SRC\C\shell\bin\mkdir.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin\
copy %EIFFEL_SRC\C\shell\bin\*.dll %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin\
safe_md %STUDIO_DIR\studio\spec\%ISE_PLATFORM\etc
echo Dummy >> %STUDIO_DIR\studio\spec\%ISE_PLATFORM\etc\dummy.txt

remtrace Then the C libraries
cd %EIFFEL_SRC\C_library
fullrd .libs

remtrace libpng
cd %EIFFEL_SRC\C_library\libpng
default_make
remtrace zlib
cd %EIFFEL_SRC\C_library\zlib
default_make

REM These directories should already have been created by make_delivery. Whatever...
safe_md %STUDIO_DIR\studio\spec
safe_md %STUDIO_DIR\studio\spec\%ISE_PLATFORM
safe_md %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace CLI writer
cd %EIFFEL_SRC\framework\cli_writer\Clib
default_make 

remtrace CLI debugger
cd %EIFFEL_SRC\framework\cli_debugger\Clib
default_make

REM Compiling EiffelStudio stuff
iff defined BUILD_ENTERPRISE_ONLY then
	remtrace Recompile EiffelStudio
	cdd %FINALIZATION_DIR
	copy %EIFFEL_SRC\Eiffel\Ace\*.* .
	copy %EIFFEL_SRC\tools\estudio_enterprise\ec.ecf ec.ecf
	iff not exist ec.ecf then
		remtrace Cannot find the finalization Ace for EiffelStudio
		CANCEL
	endiff

	remtrace Enterprise edition
	cdd %EIFFEL_SRC\Eiffel\API\constants
	set_version %EIFFEL_SRC 0000 system_constants.e
	sed -e "s/Version_type_name:\ STRING\ =\ \"GPL\ Edition\"/Version_type_name:\ STRING\ =\ \"Enterprise\ Edition\"/g" system_constants.e >> new_system_constants.e
	move new_system_constants.e system_constants.e
	cdd %FINALIZATION_DIR

	clean_project
	finalize ec.ecf bench
	cleanup_eiffel bench ec.exe
	iff not exist ec.exe then
		remtrace Could not finalize a new "enterprise_version" EiffelStudio
		CANCEL
	endiff
	move ec.exe %INSTALL_DIR\releases\enterprise_version

	clean_project
	finalize ec.ecf batch
	cleanup_eiffel batch ecb.exe
	iff not exist ecb.exe then
		remtrace Could not finalize a new batch version of the compiler
		CANCEL
	endiff
	move ecb.exe %INSTALL_DIR\releases\enterprise_version

	exprtfile -r %PUBLIC_SVN_REVISION %DEFAULT_PUBLIC_SVN/Src/Delivery/scripts/licensing/eiffelstudio/enterprise.txt > %INSTALL_DIR\releases\enterprise_version\LICENSE
else
	iff not defined NO_NEW_EC then
		remtrace GPL edition
		cdd %EIFFEL_SRC\Eiffel\API\constants
		set_version %EIFFEL_SRC 0000 system_constants.e
		cdd %FINALIZATION_DIR
		copy %EIFFEL_SRC\Eiffel\Ace\*.* .
		clean_project
		finalize ec.ecf bench
		cleanup_eiffel bench ec.exe
		iff not exist ec.exe then
			remtrace Could not finalize a new "gpl_edition" EiffelStudio
			CANCEL
		endiff
		move ec.exe %INSTALL_DIR\releases\gpl_version

		clean_project
		finalize ec.ecf batch
		cleanup_eiffel batch ecb.exe
		iff not exist ecb.exe then
			remtrace Could not finalize a new batch version of the compiler
			CANCEL
		endiff
		move ecb.exe %INSTALL_DIR\releases\gpl_version

		exprtfile -r %PUBLIC_SVN_REVISION %DEFAULT_PUBLIC_SVN/Src/Delivery/scripts/licensing/eiffelstudio/gpl.txt > %INSTALL_DIR\releases\gpl_version\LICENSE

		remtrace Enterprise edition for EiffelStudio
		cdd %EIFFEL_SRC\Eiffel\API\constants
		sed -e "s/Version_type_name:\ STRING\ =\ \"GPL\ Edition\"/Version_type_name:\ STRING\ =\ \"Enterprise\ Edition\"/g" system_constants.e >> new_system_constants.e
		move new_system_constants.e system_constants.e
		cdd %FINALIZATION_DIR
		clean_project
		copy %EIFFEL_SRC\tools\estudio_enterprise\ec.ecf ec.ecf
		finalize ec.ecf bench
		cleanup_eiffel bench ec.exe
		iff not exist ec.exe then
			remtrace Could not finalize a new "enterprise_version" EiffelStudio
			CANCEL
		endiff
		move ec.exe %INSTALL_DIR\releases\enterprise_version

		clean_project
		finalize ec.ecf batch
		cleanup_eiffel batch ecb.exe
		iff not exist ecb.exe then
			remtrace Could not finalize a new batch version of the compiler
			CANCEL
		endiff
		move ecb.exe %INSTALL_DIR\releases\enterprise_version

		exprtfile -r %PUBLIC_SVN_REVISION %DEFAULT_PUBLIC_SVN/Src/Delivery/scripts/licensing/eiffelstudio/gpl.txt > %INSTALL_DIR\releases\enterprise_version\LICENSE
	endiff
endiff

remtrace Recompile finish_freezing
cdd %EIFFEL_SRC\tools\finish_freezing
cd Clib
default_make 
cd ..
clean_project
finalize finish_freezing.ecf finish_freezing
cleanup_eiffel finish_freezing finish_freezing.exe
iff not exist finish_freezing.exe then
	remtrace Could not finalize a new finish_freezing
	CANCEL
endiff
move finish_freezing.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace Recompile emake
cdd %EIFFEL_SRC\tools\eiffel_make
clean_project
finalize emake.ecf
cleanup_eiffel emake emake.exe
iff not exist emake.exe then
	remtrace Could not finalize a new emake
	CANCEL
endiff
move emake.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace Recompile quick_finalize
cdd %EIFFEL_SRC\tools\quick_finalize
clean_project
finalize quick_finalize.ecf
cleanup_eiffel quick_finalize quick_finalize.exe
iff not exist quick_finalize.exe then
	remtrace Could not finalize a new quick_finalize
	CANCEL
endiff
move quick_finalize.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace Put ecdbgd.exe in the new delivery
REM It should already have been compiled by the configure of the run-time.
cdd %EIFFEL_SRC\C\ipc\daemon
iff not exist ecdbgd.exe then
	remtrace Could not finalize a new ecdbgd
	CANCEL
endiff
move ecdbgd.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace Put x2c.exe in the new delivery
REM It should already have been compiled by the configure of the run-time.
cdd %EIFFEL_SRC\C\run-time
iff not exist x2c.exe then
	remtrace Could not finalize a new x2c
	CANCEL
endiff
move x2c.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace Recompile h2e
cdd %EIFFEL_SRC\library\wel\extra
clean_project
finalize h2e.ecf
cleanup_eiffel h2e h2e.exe
iff not exist h2e.exe then
	remtrace Could not finalize a new h2e
	CANCEL
endiff
move h2e.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin


remtrace Recompile estudio.exe
cdd %EIFFEL_SRC\tools\estudio\config
clean_project
finalize estudio.ecf estudio
cleanup_eiffel estudio estudio.exe
iff not exist estudio.exe then
	remtrace Could not finalize a new estudio
	CANCEL
endiff
move estudio.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace get GDI+ for platforms that don't have it
cdd %EIFFEL_SRC\tools
co %DEFAULT_ISE_SVN/Src/tools/gdiplus gdiplus
move gdiplus\gdiplus.dll %INSTALL_DIR\releases

remtrace Recompiling EiffelBuild
cdd %INIT_DIR
call inc\make_esbuilder.btm

remtrace Recompiling Vision2 tour
cdd %INIT_DIR
call inc\make_vision2_demo.btm

remtrace Recompile Legacy++
cdd %EIFFEL_SRC\tools\legacy\PCCTS
safe_md bin
espawn -u:%ISE_C_COMPILER_VER% "%COMSPEC% /c nmake -f makefile.win"
cd ..
cd legacy
espawn -u:%ISE_C_COMPILER_VER% "%COMSPEC% /c nmake -f makefile.win"
iff not exist legacy.exe then
	remtrace Couldnt generate legacy.exe
	CANCEL
endiff
move legacy.exe %STUDIO_DIR\studio\spec\%ISE_PLATFORM\bin

remtrace Getting eweasel source code
safe_md %EIFFEL_SRC\eweasel
co -r %PUBLIC_SVN_REVISION %DEFAULT_PUBLIC_SVN/eweasel/source %EIFFEL_SRC\eweasel\source
remtrace Compiling eweasel
safe_md %STUDIO_DIR\eweasel
safe_md %STUDIO_DIR\eweasel\spec
safe_md %STUDIO_DIR\eweasel\spec\%ISE_PLATFORM
safe_md %STUDIO_DIR\eweasel\spec\%ISE_PLATFORM\bin
cdd %EIFFEL_SRC\eweasel\source
clean_project
set OLD_EWEASEL=%EWEASEL
set EWEASEL=%EIFFEL_SRC\eweasel
finalize eweasel.ecf eweasel_st
cleanup_eiffel eweasel_st eweasel.exe
move eweasel.exe %STUDIO_DIR\eweasel\spec\%ISE_PLATFORM\bin
finalize eweasel.ecf eweasel_mt
cleanup_eiffel eweasel_mt eweasel-mt.exe
move eweasel-mt.exe %STUDIO_DIR\eweasel\spec\%ISE_PLATFORM\bin
set EWEASEL=%OLD_EWEASEL
set OLD_EWEASEL=

remtrace Compiling Eiffel Software tools
cdd %INIT_DIR
call inc\make_tools.btm

remtrace Compiling Gobo tools
safe_md %STUDIO_DIR\library\gobo\spec
safe_md %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM
safe_md %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin
cdd %EIFFEL_SRC\library\gobo\src
clean_project
remtrace geant
finalize geant.ecf geant
cleanup_eiffel geant geant.exe
move geant.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace gec
finalize gec.ecf gec
cleanup_eiffel gec gec.exe
move gec.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace gelex
finalize gelex.ecf gelex
cleanup_eiffel gelex gelex.exe
move gelex.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace gelint
finalize gelint.ecf gelint
cleanup_eiffel gelint gelint.exe
move gelint.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace gepp
finalize gepp.ecf gepp
cleanup_eiffel gepp gepp.exe
move gepp.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace getest
finalize getest.ecf getest
cleanup_eiffel getest getest.exe
move getest.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace gexace
finalize gexace.ecf gexace
cleanup_eiffel gexace gexace.exe
move gexace.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace gexslt
finalize gexslt.ecf gexslt
cleanup_eiffel gexslt gexslt.exe
move gexslt.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace geyacc
finalize geyacc.ecf geyacc
cleanup_eiffel geyacc geyacc.exe
move geyacc.exe %STUDIO_DIR\library\gobo\spec\%ISE_PLATFORM\bin

remtrace Compiling .NET components
cdd %INIT_DIR
call inc\make_dotnet.btm
cdd %EIFFEL_SRC
