Imported Upstream version 7.59.0
[platform/upstream/curl.git] / projects / build-openssl.bat
index 0773e07..21709b7 100644 (file)
@@ -6,7 +6,7 @@ rem *                             / __| | | | |_) | |
 rem *                            | (__| |_| |  _ <| |___
 rem *                             \___|\___/|_| \_\_____|
 rem *
-rem * Copyright (C) 2012 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+rem * Copyright (C) 2012 - 2018, Steve Holme, <steve_holme@hotmail.com>.
 rem *
 rem * This software is licensed as described in the file COPYING, which
 rem * you should have received as part of this distribution. The terms
@@ -33,6 +33,16 @@ rem ***************************************************************************
   rem Ensure we have the required arguments
   if /i "%~1" == "" goto syntax
 
+  rem Calculate the program files directory
+  if defined PROGRAMFILES (
+    set "PF=%PROGRAMFILES%"
+    set OS_PLATFORM=x86
+  )
+  if defined PROGRAMFILES(x86) (
+    set "PF=%PROGRAMFILES(x86)%"
+    set OS_PLATFORM=x64
+  )
+
 :parseArgs
   if "%~1" == "" goto prerequisites
 
@@ -72,6 +82,19 @@ rem ***************************************************************************
     set VC_VER=14.0
     set VC_DESC=VC14
     set "VC_PATH=Microsoft Visual Studio 14.0\VC"
+  ) else if /i "%~1" == "vc15" (
+    set VC_VER=15.0
+    set VC_DESC=VC15
+
+    rem Determine the VC15 path based on the installed edition in decending
+    rem order (Enterprise, then Professional and finally Community)
+    if exist "%PF%\Microsoft Visual Studio\2017\Enterprise\VC" (
+      set "VC_PATH=Microsoft Visual Studio\2017\Enterprise\VC"
+    ) else if exist "%PF%\Microsoft Visual Studio\2017\Professional\VC" (
+      set "VC_PATH=Microsoft Visual Studio\2017\Professional\VC"
+    ) else (
+      set "VC_PATH=Microsoft Visual Studio\2017\Community\VC"
+    )
   ) else if /i "%~1%" == "x86" (
     set BUILD_PLATFORM=x86
   ) else if /i "%~1%" == "x64" (
@@ -97,23 +120,12 @@ rem ***************************************************************************
   shift & goto parseArgs
 
 :prerequisites
-  rem Compiler and platform are required parameters.
+  rem Compiler is a required parameter
   if not defined VC_VER goto syntax
-  if not defined BUILD_PLATFORM goto syntax
 
   rem Default the start directory if one isn't specified
   if not defined START_DIR set START_DIR=..\..\openssl
 
-  rem Calculate the program files directory
-  if defined PROGRAMFILES (
-    set "PF=%PROGRAMFILES%"
-    set OS_PLATFORM=x86
-  )
-  if defined PROGRAMFILES(x86) (
-    set "PF=%PROGRAMFILES(x86)%"
-    set OS_PLATFORM=x64
-  )
-
   rem Check we have a program files directory
   if not defined PF goto nopf
 
@@ -138,6 +150,9 @@ rem ***************************************************************************
   rem Check the start directory exists
   if not exist "%START_DIR%" goto noopenssl
 
+  rem Check that OpenSSL is not unsupported version 1.1.0
+  if not exist "%START_DIR%\ms\do_ms.bat" goto unsupported
+
 :configure
   if "%BUILD_PLATFORM%" == "" (
     if "%VC_VER%" == "6.0" (
@@ -163,23 +178,28 @@ rem ***************************************************************************
     if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
     if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
     if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
+    if "%VC_VER%" == "15.0" set VCVARS_PLATFORM=amd64
   )
 
 :start
   echo.
+  set SAVED_PATH=%CD%
+
   if "%VC_VER%" == "6.0" (
     call "%PF%\%VC_PATH%\bin\vcvars32"
   ) else if "%VC_VER%" == "7.0" (
     call "%PF%\%VC_PATH%\bin\vcvars32"
   ) else if "%VC_VER%" == "7.1" (
     call "%PF%\%VC_PATH%\bin\vcvars32"
+  ) else if "%VC_VER%" == "15.0" (
+    call "%PF%\%VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
   ) else (
     call "%PF%\%VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
   )
 
   echo.
-  set SAVED_PATH=%CD%
-  if defined START_DIR CD %START_DIR%
+  cd %SAVED_PATH%
+  cd %START_DIR%
   goto %BUILD_PLATFORM%
 
 :x64
@@ -199,12 +219,22 @@ rem ***************************************************************************
   nmake -f ms\ntdll.mak
 
   rem Move the output directories
-  move out32.dbg "%OUTDIR%\LIB Debug"
-  move out32dll.dbg "%OUTDIR%\DLL Debug"
+  if exist "%OUTDIR%\LIB Debug" (
+    copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
+    rd out32.dbg /s /q
+  ) else (
+    move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
+  )
+  if exist "%OUTDIR%\DLL Debug" (
+    copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
+    rd out32dll.dbg /s /q
+  ) else (
+    move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
+  )
 
   rem Move the PDB files
-  move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug"
-  move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug"
+  move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
+  move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
   
   rem Remove the intermediate directories
   rd tmp32.dbg /s /q
@@ -220,14 +250,24 @@ rem ***************************************************************************
   call ms\do_win64a
   nmake -f ms\nt.mak
   nmake -f ms\ntdll.mak
-  
+
   rem Move the output directories
-  move out32 "%OUTDIR%\LIB Release"
-  move out32dll "%OUTDIR%\DLL Release"
+  if exist "%OUTDIR%\LIB Release" (
+    copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
+    rd out32 /s /q
+  ) else (
+    move out32 "%OUTDIR%\LIB Release" 1>nul
+  )
+  if exist "%OUTDIR%\DLL Release" (
+    copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
+    rd out32dll /s /q
+  ) else (
+    move out32dll "%OUTDIR%\DLL Release" 1>nul
+  )
 
   rem Move the PDB files
-  move tmp32\lib.pdb "%OUTDIR%\LIB Release"
-  move tmp32dll\lib.pdb "%OUTDIR%\DLL Release"
+  move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
+  move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
 
   rem Remove the intermediate directories
   rd tmp32 /s /q
@@ -252,12 +292,22 @@ rem ***************************************************************************
   nmake -f ms\ntdll.mak
 
   rem Move the output directories
-  move out32.dbg "%OUTDIR%\LIB Debug"
-  move out32dll.dbg "%OUTDIR%\DLL Debug"
+  if exist "%OUTDIR%\LIB Debug" (
+    copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
+    rd out32.dbg /s /q
+  ) else (
+    move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
+  )
+  if exist "%OUTDIR%\DLL Debug" (
+    copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
+    rd out32dll.dbg /s /q
+  ) else (
+    move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
+  )
 
   rem Move the PDB files
-  move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug"
-  move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug"
+  move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
+  move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
 
   rem Remove the intermediate directories
   rd tmp32.dbg /s /q
@@ -273,14 +323,24 @@ rem ***************************************************************************
   call ms\do_ms
   nmake -f ms\nt.mak
   nmake -f ms\ntdll.mak
-  
+
   rem Move the output directories
-  move out32 "%OUTDIR%\LIB Release"
-  move out32dll "%OUTDIR%\DLL Release"
+  if exist "%OUTDIR%\LIB Release" (
+    copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
+    rd out32 /s /q
+  ) else (
+    move out32 "%OUTDIR%\LIB Release" 1>nul
+  )
+  if exist "%OUTDIR%\DLL Release" (
+    copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
+    rd out32dll /s /q
+  ) else (
+    move out32dll "%OUTDIR%\DLL Release" 1>nul
+  )
 
   rem Move the PDB files
-  move tmp32\lib.pdb "%OUTDIR%\LIB Release"
-  move tmp32dll\lib.pdb "%OUTDIR%\DLL Release"
+  move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
+  move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
 
   rem Remove the intermediate directories
   rd tmp32 /s /q
@@ -291,7 +351,7 @@ rem ***************************************************************************
 :syntax
   rem Display the help
   echo.
-  echo Usage: build-openssl ^<compiler^> ^<platform^> [configuration] [directory]
+  echo Usage: build-openssl ^<compiler^> [platform] [configuration] [directory]
   echo.
   echo Compiler:
   echo.
@@ -304,6 +364,7 @@ rem ***************************************************************************
   echo vc11      - Use Visual Studio 2012
   echo vc12      - Use Visual Studio 2013
   echo vc14      - Use Visual Studio 2015
+  echo vc15      - Use Visual Studio 2017
   echo.
   echo Platform:
   echo.
@@ -355,6 +416,14 @@ rem ***************************************************************************
   echo Error: Cannot locate OpenSSL source directory
   goto error
 
+:unsupported
+  echo.
+  echo Error: Unsupported OpenSSL version.
+  echo The pre-generated project files and this build script only support the
+  echo LTS version of OpenSSL ^(v1.0.2^). The next version of this build script
+  echo will support OpenSSL v1.1.0.
+  goto error
+
 :error
   if "%OS%" == "Windows_NT" endlocal
   exit /B 1