Commit c4e0be44 authored by Steve Holme's avatar Steve Holme
Browse files

build-openssl.bat: Fixed support for OpenSSL v1.1.0+

parent b1923b90
Loading
Loading
Loading
Loading
+240 −117
Original line number Diff line number Diff line
@@ -176,9 +176,6 @@ 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

:setup
  if "%BUILD_PLATFORM%" == "" (
    if "%VC_VER%" == "6.0" (
@@ -207,6 +204,12 @@ rem ***************************************************************************
    if "%VC_VER%" == "14.1" set VCVARS_PLATFORM=amd64
  )

  if exist "%START_DIR%\ms\do_ms.bat" (
    set LEGACY_BUILD=TRUE
  ) else (
    set LEGACY_BUILD=FALSE
  )

:start
  echo.
  set SAVED_PATH=%CD%
@@ -234,37 +237,43 @@ rem ***************************************************************************
  if not exist %OUTDIR% md %OUTDIR%

  if not "%BUILD_CONFIG%" == "release" (
    rem Configuring 64-bit Debug Build
    call :configure x64 debug
    rem Configuring 64-bit Static Library Debug Build
    call :configure x64 debug static %LEGACY_BUILD%

    rem Perform the build
    call :build x64 static %LEGACY_BUILD%

    rem Perform the static library build
    call :build x64 static
    rem Perform the install
    call :install debug static %LEGACY_BUILD%

    rem Perform the static library install
    call :install debug static
    rem Configuring 64-bit Shared Library Debug Build
    call :configure x64 debug shared %LEGACY_BUILD%

    rem Perform the 64-bit shared library build
    call :build x64 shared
    rem Perform the build
    call :build x64 shared %LEGACY_BUILD%

    rem Perform the shared library install
    call :install debug shared
    rem Perform the install
    call :install debug shared %LEGACY_BUILD%
  )

  if not "%BUILD_CONFIG%" == "debug" (
    rem Configuring 64-bit Release Build
    call :configure x64 release
    rem Configuring 64-bit Static Library Release Build
    call :configure x64 release static %LEGACY_BUILD%

    rem Perform the static library build
    call :build x64 static
    rem Perform the build
    call :build x64 static %LEGACY_BUILD%

    rem Perform the static library install
    call :install release static
    rem Perform the install
    call :install release static %LEGACY_BUILD%

    rem Perform the shared library build
    call :build x64 shared
    rem Configuring 64-bit Shared Library Release Build
    call :configure x64 release shared %LEGACY_BUILD%

    rem Perform the shared library install
    call :install release shared
    rem Perform the build
    call :build x64 shared %LEGACY_BUILD%

    rem Perform the install
    call :install release shared %LEGACY_BUILD%
  )

  goto success
@@ -275,37 +284,43 @@ rem ***************************************************************************
  if not exist %OUTDIR% md %OUTDIR%

  if not "%BUILD_CONFIG%" == "release" (
    rem Configuring 32-bit Debug Build
    call :configure x86 debug
    rem Configuring 32-bit Static Library Debug Build
    call :configure x86 debug static %LEGACY_BUILD%

    rem Perform the build
    call :build x86 static %LEGACY_BUILD%

    rem Perform the static library build
    call :build x86 static
    rem Perform the install
    call :install debug static %LEGACY_BUILD%

    rem Perform the static library install
    call :install debug static
    rem Configuring 32-bit Shared Library Debug Build
    call :configure x86 debug shared %LEGACY_BUILD%

    rem Perform the shared library build
    call :build x86 shared
    rem Perform the build
    call :build x86 shared %LEGACY_BUILD%

    rem Perform the shared library install
    call :install debug shared
    rem Perform the install
    call :install debug shared %LEGACY_BUILD%
  )

  if not "%BUILD_CONFIG%" == "debug" (
    rem Configuring 32-bit Release Build
    call :configure x86 release
    rem Configuring 32-bit Static Library Release Build
    call :configure x86 release static %LEGACY_BUILD%

    rem Perform the static library build
    call :build x86 static
    rem Perform the build
    call :build x86 static %LEGACY_BUILD%

    rem Perform the static library install
    call :install release static
    rem Perform the install
    call :install release static %LEGACY_BUILD%

    rem Perform the shared library build
    call :build x86 shared
    rem Configuring 32-bit Shared Library Release Build
    call :configure x86 release shared %LEGACY_BUILD%

    rem Perform the shared library install
    call :install release shared
    rem Perform the build
    call :build x86 shared %LEGACY_BUILD%

    rem Perform the install
    call :install release shared %LEGACY_BUILD%
  )

  goto success
@@ -314,13 +329,22 @@ rem Function to configure the build.
rem
rem %1 - Platform (x86 or x64)
rem %2 - Configuration (release or debug)
rem %3 - Build Type (static or shared)
rem %4 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
rem
:configure
  setlocal

  if "%1" == "" exit /B 1
  if "%2" == "" exit /B 1
  if "%3" == "" exit /B 1
  if "%4" == "" exit /B 1

  if "%4" == "TRUE" (
    rem Calculate the build directory
    set build_dir=%cd%

    rem Calculate the configure options
    if "%1" == "x86" (
      if "%2" == "debug" (
        set options=debug-VC-WIN32
@@ -342,8 +366,48 @@ rem
    ) else (
      exit /B 1
    )
  ) else if "%4" == "FALSE" (
    rem Has configure already been ran?
    if exist makefile (
      rem Clean up the previous build
      nmake clean

  set options=%options% --prefix=%CD%
      rem Remove the old makefile
      del makefile 1>nul
    )

    rem Calculate the build directory
    set build_dir=%cd%\build\tmp

    rem Calculate the configure options
    if "%1" == "x86" (
      set options=VC-WIN32
    ) else if "%1" == "x64" (
      set options=VC-WIN64A
    ) else (
      exit /B 1
    )

    if "%2" == "debug" (
      set options=!options! --debug
    ) else if "%2" == "release" (
      set options=!options! --release
    ) else (
      exit /B 1
    )

    if "%3" == "static" (
      set options=!options! no-shared
    ) else if not "%3" == "shared" (
      exit /B 1
    )

    set options=!options! no-asm
  ) else (
    exit /B 1
  )

  set options=%options% --prefix=%build_dir%

  rem Run the configure
  perl Configure %options%
@@ -354,13 +418,16 @@ rem Main build function.
rem
rem %1 - Platform (x86 or x64)
rem %2 - Build Type (static or shared)
rem %3 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
rem
:build
  setlocal

  if "%1" == "" exit /B 1
  if "%2" == "" exit /B 1
  if "%3" == "" exit /B 1

  if "%3" == "TRUE" (
    if "%1" == "x86" (
      call ms\do_ms.bat
    ) else if "%1" == "x64" (
@@ -376,6 +443,11 @@ rem
    ) else (
      exit /B 1
    )
  ) else if "%2" == "FALSE" (
    nmake
  ) else (
    exit /B 1
  )

  exit /B 0

@@ -383,14 +455,17 @@ rem Main installation function.
rem
rem %1 - Configuration (release or debug)
rem %2 - Build Type (static or shared)
rem %3 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
rem
:install
  setlocal

  if "%1" == "" exit /B 1
  if "%2" == "" exit /B 1
  if "%3" == "" exit /B 1

  rem Copy the generated files to our directory structure
  if "%3" == "TRUE" (
    if "%1" == "debug" (
      if "%2" == "static" (
        rem Move the output directories
@@ -454,6 +529,62 @@ rem
        exit /B 1
      )
    )
  ) else if "%3" == "FALSE" (
    rem Calculate the build directory
    set build_dir=%cd%\build\tmp

    rem Perform the installation
    nmake install_sw

    rem Move the output directories
    if "%1" == "debug" (
      if "%2" == "static" (
        if not exist "%OUTDIR%\LIB Debug" (
          mkdir "%OUTDIR%\LIB Debug" 1>nul
        )

        move !build_dir!\lib\*.lib "%OUTDIR%\LIB Debug" 1>nul
        move !build_dir!\bin\*.exe "%OUTDIR%\LIB Debug" 1>nul
      ) else if "%2" == "shared" (
        if not exist "%OUTDIR%\DLL Debug" (
          mkdir "%OUTDIR%\DLL Debug" 1>nul
        )

        move !build_dir!\lib\*.lib "%OUTDIR%\DLL Debug" 1>nul
        move !build_dir!\bin\*.dll "%OUTDIR%\DLL Debug" 1>nul
        move !build_dir!\bin\*.exe "%OUTDIR%\DLL Debug" 1>nul
        move !build_dir!\bin\*.pdb "%OUTDIR%\DLL Debug" 1>nul
      ) else (
        exit /B 1
      )
    ) else if "%1" == "release" (
      if "%2" == "static" (
        if not exist "%OUTDIR%\LIB Release" (
          mkdir "%OUTDIR%\LIB Release" 1>nul
        )

        move !build_dir!\lib\*.lib "%OUTDIR%\LIB Release" 1>nul
        move !build_dir!\bin\*.exe "%OUTDIR%\LIB Release" 1>nul
      ) else if "%2" == "shared" (
        if not exist "%OUTDIR%\DLL Release" (
          mkdir "%OUTDIR%\DLL Release" 1>nul
        )
  
        move !build_dir!\lib\*.lib "%OUTDIR%\DLL Release" 1>nul
        move !build_dir!\bin\*.dll "%OUTDIR%\DLL Release" 1>nul
        move !build_dir!\bin\*.exe "%OUTDIR%\DLL Release" 1>nul
      ) else (
        exit /B 1
      )
    ) else (
      exit /B 1
    )

    rem Remove the output directories
    rd !build_dir! /s /q
  ) else (
    exit /B 1
  )

  exit /B 0

@@ -537,14 +668,6 @@ 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