1::
2:: Licensed under the Apache License, Version 2.0 (the "License");
3:: you may not use this file except in compliance with the License.
4:: You may obtain a copy of the License at
5::
6::     http://www.apache.org/licenses/LICENSE-2.0
7::
8:: Unless required by applicable law or agreed to in writing, software
9:: distributed under the License is distributed on an "AS IS" BASIS,
10:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11:: See the License for the specific language governing permissions and
12:: limitations under the License.
13::
14
15SETLOCAL EnableDelayedExpansion
16
17SET PACKAGE=zlib-%ZLIB_VERSION%
18SET BUILDDIR=%WIN3P%\zlib-build
19SET INSTDIR=%WIN3P%\zlib-inst
20SET SRCDIR=%WIN3P%\%PACKAGE%
21SET URLFILE=%PACKAGE%.tar.gz
22
23:: This allows us to tolerate when the current version is archived
24SET URL=http://zlib.net/%URLFILE%
25SET FURL=http://zlib.net/fossils/%URLFILE%
26
27:: Download - support running a local build or a build in appveyor
28CD "%WIN3P%" || EXIT /B
29IF "%APPVEYOR_BUILD_ID%" == "" (
30    curl -L -f -o "%URLFILE%" "%URL%"
31    IF ERRORLEVEL 1 (
32        curl -L -f -o "%URLFILE%" "%FURL%"
33    )
34) ELSE (
35    appveyor DownloadFile "%URL%"
36    IF ERRORLEVEL 1 (
37        appveyor DownloadFile "%FURL%" || EXIT /B
38    )
39)
407z x "%URLFILE%" -so | 7z x -si -ttar > nul || EXIT /B
41
42:: Generate
43MKDIR "%BUILDDIR%" || EXIT /B
44CD "%BUILDDIR%" || EXIT /B
45cmake "%SRCDIR%" ^
46      -G"NMake Makefiles" ^
47      -DCMAKE_INSTALL_PREFIX="%INSTDIR%" ^
48      -DCMAKE_BUILD_TYPE="%CONFIGURATION%" || EXIT /B
49
50:: Build
51nmake /fMakefile install || EXIT /B
52IF "%CONFIGURATION%" == "Debug" (
53    COPY "%BUILDDIR%\zlibd.pdb" "%INSTDIR%\bin\" || EXIT /B
54)
55
56ENDLOCAL
57