James E. King, III | 4d651ab | 2017-02-19 22:19:55 -0500 | [diff] [blame] | 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 | |
| 15 | :: |
| 16 | :: Build script for zlib on windows. |
| 17 | :: Uses the environment set up by a Visual Studio Command Prompt shortcut |
| 18 | :: to target a specific architecture and compiler. |
| 19 | :: |
| 20 | |
| 21 | @ECHO OFF |
| 22 | SETLOCAL EnableDelayedExpansion |
| 23 | |
| 24 | :: Sets variables for third party versions used in build |
| 25 | CALL ..\..\scripts\tpversions.bat || EXIT /B |
| 26 | |
| 27 | :: use "build-zlib.bat /yes" to skip the question part |
| 28 | IF /I "%1" == "/YES" SET NOASK=1 |
| 29 | |
| 30 | IF NOT DEFINED GENERATOR SET GENERATOR=NMake Makefiles |
| 31 | IF NOT DEFINED PACKAGE_NAME SET PACKAGE_NAME=zlib |
| 32 | IF NOT DEFINED PACKAGE_VERSION SET PACKAGE_VERSION=%TP_ZLIB_VERSION% |
| 33 | IF NOT DEFINED SOURCE_DIR SET SOURCEDIR=%~dp0%PACKAGE_NAME%-%PACKAGE_VERSION% |
| 34 | IF NOT DEFINED WIN3P_ROOT SET WIN3P_ROOT=%~dp0.. |
| 35 | |
| 36 | :: Set COMPILER to (vc100 - vc140) depending on the current environment |
| 37 | CALL ..\..\scripts\cl_setcompiler.bat || EXIT /B |
| 38 | |
| 39 | :: Set ARCH to either win32 or x64 depending on the current environment |
| 40 | CALL ..\..\scripts\cl_setarch.bat || EXIT /B |
| 41 | |
| 42 | FOR %%X IN ( |
| 43 | Debug |
| 44 | Release |
| 45 | ) DO ( |
| 46 | SET BUILDTYPE=%%X |
| 47 | SET BUILDDIR=%WIN3P_ROOT%\build\%PACKAGE_NAME%\%PACKAGE_VERSION%\%COMPILER%\%ARCH%\!BUILDTYPE! |
| 48 | SET OUTDIR=%WIN3P_ROOT%\dist\%PACKAGE_NAME%-%PACKAGE_VERSION%\%COMPILER%\%ARCH% |
| 49 | |
| 50 | ECHO/ |
| 51 | ECHO ========================================================================= |
| 52 | ECHO Building: %PACKAGE_NAME% v%PACKAGE_VERSION% %COMPILER%:%ARCH%:!BUILDTYPE! "%GENERATOR%" |
| 53 | ECHO Build Directory: !BUILDDIR! |
| 54 | ECHO Install Directory: !OUTDIR! |
| 55 | ECHO Source Directory: %SOURCEDIR% |
| 56 | ECHO ========================================================================= |
| 57 | ECHO/ |
| 58 | |
| 59 | IF NOT DEFINED NOASK ( |
| 60 | CHOICE /M "Do you want to build this configuration? " /c YN |
| 61 | IF !ERRORLEVEL! NEQ 1 (EXIT /B !ERRORLEVEL!) |
| 62 | ) |
| 63 | |
| 64 | MKDIR "!BUILDDIR!" |
| 65 | CD "!BUILDDIR!" || EXIT /B |
| 66 | |
| 67 | CMAKE.EXE -G"%GENERATOR%" -DCMAKE_INSTALL_PREFIX=!OUTDIR! -DCMAKE_BUILD_TYPE=!BUILDTYPE! "%SOURCEDIR%" || EXIT /B |
| 68 | NMAKE /fMakefile install || EXIT /B |
| 69 | |
| 70 | IF "!BUILDTYPE!" == "Debug" ( |
| 71 | COPY "!BUILDDIR!\zlibd.pdb" "!OUTDIR!\bin\" || EXIT /B |
| 72 | ) |
| 73 | ) |
| 74 | |
| 75 | ENDLOCAL |