cls
echo on
REM Batch file for making a CDex release version
REM First parameter specifies the name, like cdex_140b6
REM Second parameter specifies the language, currently the following
REM languages are supported:
REM lang_enu for the english version
REM lang_deu for the german version
REM lang_ita for the italian version
REM lang_esp for the spanish version

set LANG=%2

goto delete_files:

:delete_files

del CDex /s /q
rmdir CDex\Plugins
rmdir CDex\lang
rmdir CDex

mkdir CDex

:copy_files

cd CDex
mkdir Plugins
mkdir lang


:make_exe
del %1.exe

SET CDEX_PATH=..\..
SET LAME_PATH=..\..\..\lame

set REL_OR_RELUNI=%3

copy %CDEX_PATH%\%REL_OR_RELUNI%\cdex.exe
copy %CDEX_PATH%\CDRip\Release\CDRip.dll
copy %CDEX_PATH%\encoders\libraries\lame\Dll\lame_enc.dll
copy %CDEX_PATH%\MP2Enc\Dll\Release\MP2Enc.dll
copy %CDEX_PATH%\libsndfile\win32\%REL_OR_RELUNI%\libsndfile.dll
copy %CDEX_PATH%\encoders\libraries\libvorbis\dll\vorbis.dll
copy %CDEX_PATH%\encoders\libraries\libvorbis\dll\ogg.dll
copy %CDEX_PATH%\encoders\libraries\libvorbis\dll\vorbisenc.dll
copy %CDEX_PATH%\encoders\libraries\libape\MACDll.dll
copy %CDEX_PATH%\encoders\libraries\libFlac\Dll\libFLAC.dll
copy %CDEX_PATH%\WMA8Connect.dll
copy %CDEX_PATH%\MusicBrainz\libmusicbrainz.dll
copy %CDEX_PATH%\CDex.exe.manifest
copy %CDEX_PATH%\lang\*.cdex.lang .\lang

copy ..\CDex.ini

copy %CDEX_PATH%\hlp\cdex.hlp
copy %CDEX_PATH%\hlp\cdex.cnt
copy %CDEX_PATH%\hlp\readme.txt
copy %CDEX_PATH%\hlp\changes.txt

copy %CDEX_PATH%\Plugins\*.* Plugins
copy %CDEX_PATH%\unicows\unicows.dll


goto %2

:lang_esp
ECHO COPY SPANISH SPECIFIC LANGUAGE FILES
set LANG_EXT=_esp
REM copy %CDEX_PATH%\LangDll\Release_ESP\LangDll.dll
cd ..
copy .\esp\in_mp3.dll .\CDex\Plugins
copy .\esp\in_vorbis.dll .\CDex\Plugins
copy .\esp\CDex.txt
copy .\esp\CDex.nsi

goto lang_end


:lang_ita
ECHO COPY ITALIAN SPECIFIC LANGUAGE FILES
set LANG_EXT=_ita
REM copy %CDEX_PATH%\LangDll\Release_ITA\LangDll.dll
cd ..
copy .\ita\Leggimi.txt .\CDex
copy .\ita\cdexguida.mht .\CDex
copy .\ita\Leggimi-ITA.txt .\CDex
copy .\ita\CDex.txt
copy .\ita\CDex.nsi

goto lang_end


:lang_deu
ECHO COPY GERMAN SPECIFIC LANGUAGE FILES
set LANG_EXT=_deu
REM copy %CDEX_PATH%\LangDll\Release_DEU\LangDll.dll
cd ..
copy .\deu\liesmich.txt .\CDex
copy .\deu\CDex.txt
copy .\deu\CDex.nsi


goto lang_end

:lang_enu
ECHO COPY ENGLISH SPECIFIC LANGUAGE FILES
set LANG_EXT=_enu
cd ..
copy .\enu\CDex.txt
copy .\enu\CDex.nsi

goto lang_end


:lang_enu_unicode
ECHO COPY ENGLISH SPECIFIC LANGUAGE FILES FOR ENU UNICODE
set LANG_EXT=_enu
copy %CDEX_PATH%\Release_UNICODE\cdex.exe
copy %CDEX_PATH%\LibSndFile\Win32\Release_UNICODE\libsndfile.dll
cd ..
copy .\enu\CDex.txt
copy .\enu\CDex_UNICODE.nsi CDex.nsi

goto lang_end

:lang_end

cd CDex
REM ..\..\..\cdex_tools\upx -9 --compress-icons=0 *.exe
..\..\..\cdex_tools\upx -9 *.dll
REM ..\..\..\cdex_tools\upx -9 *.exe
cd Plugins
..\..\..\..\cdex_tools\upx -9 *.dll
cd ..
cd ..

C:\Progra~1\NSIS\makensis-bz2.exe /CD CDex.nsi
copy cdex_setup.exe %1%LANG_EXT%.exe



:make_zip
cd CDex
del ..\%1%LANG_EXT%.zip
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip cdex.cnt
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip cdex.exe
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip cdex.hlp
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip cdrip.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip unicows.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip changes.txt
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip lame_enc.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip LibSnd.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip MP2Enc.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip readme.txt
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip vorbis.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip ogg.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip vorbisenc.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip WMA8Connect.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip MacDll.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip libmusicbrainz.dll

..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\Plugins\in_vorbis.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\Plugins\in_vorbis.txt
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\Plugins\in_mp3.dll
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\Plugins\in_ape.dll

..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\lang\deutsch.cdex.lang
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\lang\english.cdex.lang
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\lang\spanish.cdex.lang
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip .\lang\italiano.cdex.lang

goto %LANG_EXT%

:_esp
goto finish

:_deu
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip liesmich.txt
goto finish

:_enu
goto finish

:_ita
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip cdexguida.mht
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip Leggimi-ITA.txt
..\..\..\cdex_tools\pacomp\pacomp.EXE -c2 -a -p ..\%1%LANG_EXT%.zip Leggimi.txt
goto finish


:finish

cd ..
