@echo off
@rem **************************************************************************
@rem * --== WARNING ==-- This is a generated file. Do not edit!
@rem *
@rem * From this directory, run this batch file like so:
@rem *
@rem *    .\build_zlib debug|release (rebuild)
@rem *
@rem **************************************************************************

@rem **************************************************************************
cd /D [zlib_path]
set exitcode=0
[if-any use_ml]
@rem **************************************************************************
@rem Compile ASM sources with ML
set ASFLAGS=-nologo -Zi -coff
set LOC=-DASMV -DASMINF
set OBJA=gvmat32c.obj gvmat32.obj inffas32.obj
set ASM_OPTS=ASFLAGS="%ASFLAGS%" LOC="%LOC%" OBJA="%OBJA%"
if not exist gvmat32c.c    copy contrib\masmx86\gvmat32c.c .
if not exist gvmat32.asm   copy contrib\masmx86\gvmat32.asm .
if not exist inffas32.asm  copy contrib\masmx86\inffas32.asm .[end]

if "%1" == "release" goto release
if "%1" == "debug" goto debug
goto pIerr

:checkrebuild
if "%2" == "rebuild" goto clean
if not "%2" == "" goto pIIerr
set target= %STATICLIB%
goto build

:clean
set target=clean %STATICLIB%
goto build

@rem **************************************************************************
:release
set STATICLIB=zlibstat.lib
set CC_OPTS=/MD /O2 /Zi
goto checkrebuild

@rem **************************************************************************
:debug
set STATICLIB=zlibstatD.lib
set CC_OPTS=/MDd /Gm /Gi /ZI /Od /GZ /D_DEBUG
goto checkrebuild

@rem **************************************************************************
:build
set COMMON_CC_OPTS=/nologo /W3 /FD /GX /DWIN32 /D_WINDOWS
set CFLAGS=%COMMON_CC_OPTS% %CC_OPTS% $(LOC)
set BUILD_OPTS=%ASM_OPTS% CFLAGS="%COMMON_CC_OPTS% %CC_OPTS% $(LOC)"
@echo nmake /f win32\Makefile.msc %BUILD_OPTS% STATICLIB=%STATICLIB% %target%
nmake /nologo /f win32\Makefile.msc %BUILD_OPTS% STATICLIB=%STATICLIB% %target%
if not errorlevel 0 goto err
goto end

@rem **************************************************************************
:pIerr
echo error: First parameter should be "release" or "debug"
goto err

@rem **************************************************************************
:pIIerr
echo error: Second parameter should be "rebuild" or empty
goto err

@rem **************************************************************************
:err
set exitcode=1
:end
exit %exitcode%
