@echo off
echo "|----------------------|"
echo "|compile file :        |"
echo "|----------------------|"
echo "|1. e [cpp]            |"
echo "|2. update             |"
echo "|3. clean              |"
echo "|4. exit               |"
echo "|----------------------|"
choice
if errorlevel 4 goto EXIT
if errorlevel 3 goto CLEAN
if errorlevel 2 goto UPDATE
if errorlevel 1 goto E

:E
echo.
echo.------------------------*
echo.Compiling...
echo.------------------------*
echo.

    set INCLUDE=
    set INCLUDE=C:\win_code\bin\ms\vs2003\SDK\v1.1\include\;C:\win_code\bin\ms\vstudio\vc\atl\include;C:\win_code\bin\ms\vstudio\vc\mfc\include;C:\win_code\bin\ms\vstudio\vc\include;C:\win_code\sdk\ms\dx9\Include\;C:\win_code\src\born\bin\bin.general\fx.7\
    set LIB=
    set LIB=C:\win_code\bin\ms\vs2003\SDK\v1.1\Lib\;C:\win_code\bin\ms\vstudio\vc\mfc\lib;C:\win_code\bin\ms\vstudio\vc\lib;C:\win_code\sdk\ms\dx9\Lib;C:\win_code\src\born\bin\bin.general\fx.7\cg\

    @cl /FAs /GX /c e_inc.cpp

echo.
if not errorlevel 0 goto ERROR
if errorlevel     0 goto LINK

:RC
echo.
echo.------------------------*
echo.Compiling resources...
echo.------------------------*
echo.

    @rc /fo "e_resource.res" res/e_resource.rc

if not errorlevel 0 goto ERROR
if errorlevel     0 goto ASM

:ASM
echo.
echo.------------------------*
echo.Assembling...
echo.------------------------*
echo.

    @ml /c /Zi /coff /Cx /Cp src/a_functions.asm

echo.
if not errorlevel 0 goto ERROR
if     errorlevel 0 goto LINK

:LINK
echo.
echo.------------------------*
echo.Linking...
echo.------------------------*
echo.

    @link /noentry /defaultlib:kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib comctl32.lib d3dx9.lib d3d9.lib cg.lib cgD3D9.lib lib/libml.lib lib/libsys.lib lib/libstr.lib lib/libimg.lib lib/jpeg.lib /subsystem:windows /out:e.exe e_inc.obj
rem @link /noentry /defaultlib:kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib comctl32.lib ../lib/libml.lib ../lib/libsys.lib ../lib/libstr.lib ../lib/lib2d.lib ../lib/jpeg.lib ../lib/glut32.lib /dll /def:"src/e.def" /out:e.dll
rem kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"Debug/GameD3DRenderer.pdb" /debug /machine:I386 /def:".\GameD3DRenderer.def" /out:"../Debug/GameD3DRenderer.dll" /implib:"Debug/GameD3DRenderer.lib" /pdbtype:sept 

if not errorlevel 0 goto ERROR
if errorlevel     0 goto EXIT

:UPDATE
echo.
echo.------------------------*
echo.Updating...
echo.------------------------*
echo.

rem @copy .exe       bin\

if not errorlevel 0 goto ERROR
if errorlevel     0 goto EXIT

:CLEAN
echo.
echo.------------------------*
echo.Cleaning...
echo.------------------------*
echo.
del e.exe
del *.obj
del *.res

if not errorlevel 0 goto ERROR
if errorlevel     0 goto EXIT

:ERROR
echo.
echo.------------------------*
echo There was an error compiling.
echo Exiting...
echo.------------------------*
echo.

pause

:EXIT
@if exist *.obj (del *.obj) else echo *.obj missing
@if exist *.res (del *.res) else echo *.res missing