xref: /curl/projects/build-openssl.bat (revision 6343034d)
1@echo off
2rem ***************************************************************************
3rem *                                  _   _ ____  _
4rem *  Project                     ___| | | |  _ \| |
5rem *                             / __| | | | |_) | |
6rem *                            | (__| |_| |  _ <| |___
7rem *                             \___|\___/|_| \_\_____|
8rem *
9rem * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
10rem *
11rem * This software is licensed as described in the file COPYING, which
12rem * you should have received as part of this distribution. The terms
13rem * are also available at https://curl.se/docs/copyright.html.
14rem *
15rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16rem * copies of the Software, and permit persons to whom the Software is
17rem * furnished to do so, under the terms of the COPYING file.
18rem *
19rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20rem * KIND, either express or implied.
21rem *
22rem * SPDX-License-Identifier: curl
23rem *
24rem ***************************************************************************
25
26:begin
27  rem Check we are running on a Windows NT derived OS
28  if not "%OS%" == "Windows_NT" goto nodos
29
30  rem Set our variables
31  setlocal ENABLEDELAYEDEXPANSION
32  set BUILD_CONFIG=
33  set BUILD_PLATFORM=
34  set SAVED_PATH=
35  set SOURCE_PATH=
36  set TMP_BUILD_PATH=
37  set TMP_INSTALL_PATH=
38  set VC_VER=
39
40  rem Ensure we have the required arguments
41  if /i "%~1" == "" goto syntax
42
43  rem Calculate the program files directory
44  if defined PROGRAMFILES (
45    set "PF=%PROGRAMFILES%"
46    set OS_PLATFORM=x86
47  )
48  if defined PROGRAMFILES(x86) (
49    rem Visual Studio was x86-only prior to 14.3
50    if /i "%~1" == "vc14.3" (
51      set "PF=%PROGRAMFILES%"
52    ) else (
53      set "PF=%PROGRAMFILES(x86)%"
54    )
55    set OS_PLATFORM=x64
56  )
57
58:parseArgs
59  if not "%~1" == "" (
60    if /i "%~1" == "vc10" (
61      set VC_VER=10.0
62      set VC_DESC=VC10
63      set "VC_PATH=Microsoft Visual Studio 10.0\VC"
64    ) else if /i "%~1" == "vc11" (
65      set VC_VER=11.0
66      set VC_DESC=VC11
67      set "VC_PATH=Microsoft Visual Studio 11.0\VC"
68    ) else if /i "%~1" == "vc12" (
69      set VC_VER=12.0
70      set VC_DESC=VC12
71      set "VC_PATH=Microsoft Visual Studio 12.0\VC"
72    ) else if /i "%~1" == "vc14" (
73      set VC_VER=14.0
74      set VC_DESC=VC14
75      set "VC_PATH=Microsoft Visual Studio 14.0\VC"
76    ) else if /i "%~1" == "vc14.1" (
77      set VC_VER=14.1
78      set VC_DESC=VC14.10
79
80      rem Determine the VC14.1 path based on the installed edition in descending
81      rem order (Enterprise, then Professional and finally Community)
82      if exist "%PF%\Microsoft Visual Studio\2017\Enterprise\VC" (
83        set "VC_PATH=Microsoft Visual Studio\2017\Enterprise\VC"
84      ) else if exist "%PF%\Microsoft Visual Studio\2017\Professional\VC" (
85        set "VC_PATH=Microsoft Visual Studio\2017\Professional\VC"
86      ) else (
87        set "VC_PATH=Microsoft Visual Studio\2017\Community\VC"
88      )
89    ) else if /i "%~1" == "vc14.2" (
90      set VC_VER=14.2
91      set VC_DESC=VC14.20
92
93      rem Determine the VC14.2 path based on the installed edition in descending
94      rem order (Enterprise, then Professional and finally Community)
95      if exist "%PF%\Microsoft Visual Studio\2019\Enterprise\VC" (
96        set "VC_PATH=Microsoft Visual Studio\2019\Enterprise\VC"
97      ) else if exist "%PF%\Microsoft Visual Studio\2019\Professional\VC" (
98        set "VC_PATH=Microsoft Visual Studio\2019\Professional\VC"
99      ) else (
100        set "VC_PATH=Microsoft Visual Studio\2019\Community\VC"
101      )
102    ) else if /i "%~1" == "vc14.3" (
103      set VC_VER=14.3
104      set VC_DESC=VC14.30
105
106      rem Determine the VC14.3 path based on the installed edition in descending
107      rem order (Enterprise, then Professional and finally Community)
108      if exist "%PF%\Microsoft Visual Studio\2022\Enterprise\VC" (
109        set "VC_PATH=Microsoft Visual Studio\2022\Enterprise\VC"
110      ) else if exist "%PF%\Microsoft Visual Studio\2022\Professional\VC" (
111        set "VC_PATH=Microsoft Visual Studio\2022\Professional\VC"
112      ) else (
113        set "VC_PATH=Microsoft Visual Studio\2022\Community\VC"
114      )
115    ) else if /i "%~1%" == "x86" (
116      set BUILD_PLATFORM=x86
117    ) else if /i "%~1%" == "x64" (
118      set BUILD_PLATFORM=x64
119    ) else if /i "%~1%" == "debug" (
120      set BUILD_CONFIG=debug
121    ) else if /i "%~1%" == "release" (
122      set BUILD_CONFIG=release
123    ) else if /i "%~1" == "-?" (
124      goto syntax
125    ) else if /i "%~1" == "-h" (
126      goto syntax
127    ) else if /i "%~1" == "-help" (
128      goto syntax
129    ) else if /i "%~1" == "-VSpath" (
130      if "%~2" == "" (
131        echo.
132        echo Error. Please provide VS Path.
133        goto error
134      ) else (
135        set "ABS_VC_PATH=%~2\VC"
136        shift
137      )
138    ) else if /i "%~1" == "-perlpath" (
139      if "%~2" == "" (
140        echo.
141        echo Error. Please provide Perl root Path.
142        goto error
143      ) else (
144        set "PERL_PATH=%~2"
145        shift
146      )
147    ) else (
148      if not defined START_DIR (
149        set "START_DIR=%~1%"
150      ) else (
151        goto unknown
152      )
153    )
154
155    shift & goto parseArgs
156  )
157
158:prerequisites
159  rem Compiler is a required parameter
160  if not defined VC_VER goto syntax
161
162  rem Default the start directory if one isn't specified
163  if not defined START_DIR set START_DIR=..\..\openssl
164
165  if not defined ABS_VC_PATH (
166    rem Check we have a program files directory
167    if not defined PF goto nopf
168    set "ABS_VC_PATH=%PF%\%VC_PATH%"
169  )
170
171  rem Check we have Visual Studio installed
172  if not exist "%ABS_VC_PATH%" goto novc
173
174  if not defined PERL_PATH (
175    rem Check we have Perl in our path
176    perl --version <NUL 1>NUL 2>&1
177    if errorlevel 1 (
178      rem It isn't so check we have it installed and set the path if it is
179      if exist "%SystemDrive%\Perl" (
180        set "PATH=%SystemDrive%\Perl\bin;%PATH%"
181      ) else (
182        if exist "%SystemDrive%\Perl64" (
183          set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
184        ) else (
185          goto noperl
186        )
187      )
188    )
189  ) else (
190    set "PATH=%PERL_PATH%\Perl\bin;%PATH%"
191  )
192
193  rem Check the start directory exists
194  if not exist "%START_DIR%" goto noopenssl
195
196:setup
197  if "%BUILD_PLATFORM%" == "" (
198    if "%VC_VER%" == "6.0" (
199      set BUILD_PLATFORM=x86
200    ) else if "%VC_VER%" == "7.0" (
201      set BUILD_PLATFORM=x86
202    ) else if "%VC_VER%" == "7.1" (
203      set BUILD_PLATFORM=x86
204    ) else (
205      set BUILD_PLATFORM=%OS_PLATFORM%
206    )
207  )
208
209  if "%BUILD_PLATFORM%" == "x86" (
210    set VCVARS_PLATFORM=x86
211  ) else if "%BUILD_PLATFORM%" == "x64" (
212    if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
213    if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
214    if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
215    if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
216    if "%VC_VER%" == "14.1" set VCVARS_PLATFORM=amd64
217    if "%VC_VER%" == "14.2" set VCVARS_PLATFORM=amd64
218    if "%VC_VER%" == "14.3" set VCVARS_PLATFORM=amd64
219  )
220
221  if exist "%START_DIR%\ms\do_ms.bat" (
222    set LEGACY_BUILD=TRUE
223  ) else (
224    set LEGACY_BUILD=FALSE
225  )
226
227:start
228  echo.
229  set "SAVED_PATH=%CD%"
230
231  if "%VC_VER%" == "14.1" (
232    call "%ABS_VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
233  ) else if "%VC_VER%" == "14.2" (
234    call "%ABS_VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
235  ) else if "%VC_VER%" == "14.3" (
236    call "%ABS_VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
237  ) else (
238    call "%ABS_VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
239  )
240
241  echo.
242
243  cd /d "%START_DIR%" || (echo Error: Failed cd start & exit /B 1)
244  rem Save the full path of the OpenSSL source dir
245  set "SOURCE_PATH=%CD%"
246
247  rem Set temporary paths for building and installing OpenSSL. If a temporary
248  rem path is not the same as the source path then it is *removed* after the
249  rem installation is completed.
250  rem
251  rem For legacy OpenSSL the temporary build path must be the source path.
252  rem
253  rem For OpenSSL 1.1.x the temporary paths must be separate not a descendant
254  rem of the other, otherwise pdb files will be lost between builds.
255  rem https://github.com/openssl/openssl/issues/10005
256  rem
257  if "%LEGACY_BUILD%" == "TRUE" (
258    set "TMP_BUILD_PATH=%SOURCE_PATH%"
259    set "TMP_INSTALL_PATH=%SOURCE_PATH%"
260  ) else (
261    set "TMP_BUILD_PATH=%SOURCE_PATH%\build\tmp_build"
262    set "TMP_INSTALL_PATH=%SOURCE_PATH%\build\tmp_install"
263  )
264
265  goto %BUILD_PLATFORM%
266
267:x64
268  rem Calculate our output directory
269  set OUTDIR=build\Win64\%VC_DESC%
270  if not exist %OUTDIR% md %OUTDIR%
271
272  if not "%BUILD_CONFIG%" == "release" (
273    rem Configuring 64-bit Static Library Debug Build
274    call :configure x64 debug static %LEGACY_BUILD%
275
276    rem Perform the build
277    call :build x64 static %LEGACY_BUILD%
278
279    rem Perform the install
280    call :install debug static %LEGACY_BUILD%
281
282    rem Configuring 64-bit Shared Library Debug Build
283    call :configure x64 debug shared %LEGACY_BUILD%
284
285    rem Perform the build
286    call :build x64 shared %LEGACY_BUILD%
287
288    rem Perform the install
289    call :install debug shared %LEGACY_BUILD%
290  )
291
292  if not "%BUILD_CONFIG%" == "debug" (
293    rem Configuring 64-bit Static Library Release Build
294    call :configure x64 release static %LEGACY_BUILD%
295
296    rem Perform the build
297    call :build x64 static %LEGACY_BUILD%
298
299    rem Perform the install
300    call :install release static %LEGACY_BUILD%
301
302    rem Configuring 64-bit Shared Library Release Build
303    call :configure x64 release shared %LEGACY_BUILD%
304
305    rem Perform the build
306    call :build x64 shared %LEGACY_BUILD%
307
308    rem Perform the install
309    call :install release shared %LEGACY_BUILD%
310  )
311
312  goto success
313
314:x86
315  rem Calculate our output directory
316  set OUTDIR=build\Win32\%VC_DESC%
317  if not exist %OUTDIR% md %OUTDIR%
318
319  if not "%BUILD_CONFIG%" == "release" (
320    rem Configuring 32-bit Static Library Debug Build
321    call :configure x86 debug static %LEGACY_BUILD%
322
323    rem Perform the build
324    call :build x86 static %LEGACY_BUILD%
325
326    rem Perform the install
327    call :install debug static %LEGACY_BUILD%
328
329    rem Configuring 32-bit Shared Library Debug Build
330    call :configure x86 debug shared %LEGACY_BUILD%
331
332    rem Perform the build
333    call :build x86 shared %LEGACY_BUILD%
334
335    rem Perform the install
336    call :install debug shared %LEGACY_BUILD%
337  )
338
339  if not "%BUILD_CONFIG%" == "debug" (
340    rem Configuring 32-bit Static Library Release Build
341    call :configure x86 release static %LEGACY_BUILD%
342
343    rem Perform the build
344    call :build x86 static %LEGACY_BUILD%
345
346    rem Perform the install
347    call :install release static %LEGACY_BUILD%
348
349    rem Configuring 32-bit Shared Library Release Build
350    call :configure x86 release shared %LEGACY_BUILD%
351
352    rem Perform the build
353    call :build x86 shared %LEGACY_BUILD%
354
355    rem Perform the install
356    call :install release shared %LEGACY_BUILD%
357  )
358
359  goto success
360
361rem Function to configure the build.
362rem
363rem %1 - Platform (x86 or x64)
364rem %2 - Configuration (release or debug)
365rem %3 - Build Type (static or shared)
366rem %4 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
367rem
368:configure
369  setlocal
370
371  if "%1" == "" exit /B 1
372  if "%2" == "" exit /B 1
373  if "%3" == "" exit /B 1
374  if "%4" == "" exit /B 1
375
376  if not exist "%TMP_BUILD_PATH%" mkdir "%TMP_BUILD_PATH%"
377  cd /d "%TMP_BUILD_PATH%" || (echo Error: Failed cd build & exit /B 1)
378
379  if "%4" == "TRUE" (
380    rem Calculate the configure options
381    if "%1" == "x86" (
382      if "%2" == "debug" (
383        set options=debug-VC-WIN32
384      ) else if "%2" == "release" (
385        set options=VC-WIN32
386      ) else (
387        exit /B 1
388      )
389
390      set options=!options! no-asm
391    ) else if "%1" == "x64" (
392      if "%2" == "debug" (
393        set options=debug-VC-WIN64A
394      ) else if "%2" == "release" (
395        set options=VC-WIN64A
396      ) else (
397        exit /B 1
398      )
399    ) else (
400      exit /B 1
401    )
402  ) else if "%4" == "FALSE" (
403    rem Has configure already been ran?
404    if exist makefile (
405      rem Clean up the previous build
406      nmake clean
407
408      rem Remove the old makefile
409      del makefile 1>nul
410    )
411
412    rem Calculate the configure options
413    if "%1" == "x86" (
414      set options=VC-WIN32
415    ) else if "%1" == "x64" (
416      set options=VC-WIN64A
417    ) else (
418      exit /B 1
419    )
420
421    if "%2" == "debug" (
422      set options=!options! --debug
423    ) else if "%2" == "release" (
424      set options=!options! --release
425    ) else (
426      exit /B 1
427    )
428
429    if "%3" == "static" (
430      set options=!options! no-shared
431    ) else if not "%3" == "shared" (
432      exit /B 1
433    )
434
435    set options=!options! no-asm
436  ) else (
437    exit /B 1
438  )
439
440  rem Run the configure
441  perl "%SOURCE_PATH%\Configure" %options% "--prefix=%TMP_INSTALL_PATH%"
442
443  exit /B %ERRORLEVEL%
444
445rem Main build function.
446rem
447rem %1 - Platform (x86 or x64)
448rem %2 - Build Type (static or shared)
449rem %3 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
450rem
451:build
452  setlocal
453
454  if "%1" == "" exit /B 1
455  if "%2" == "" exit /B 1
456  if "%3" == "" exit /B 1
457
458  cd /d "%TMP_BUILD_PATH%" || (echo Error: Failed cd build & exit /B 1)
459
460  if "%3" == "TRUE" (
461    if "%1" == "x86" (
462      call ms\do_ms.bat
463    ) else if "%1" == "x64" (
464      call ms\do_win64a.bat
465    ) else (
466      exit /B 1
467    )
468
469    if "%2" == "static" (
470      nmake -f ms\nt.mak
471    ) else if "%2" == "shared" (
472      nmake -f ms\ntdll.mak
473    ) else (
474      exit /B 1
475    )
476  ) else if "%3" == "FALSE" (
477    nmake
478  ) else (
479    exit /B 1
480  )
481
482  exit /B 0
483
484rem Main installation function.
485rem
486rem %1 - Configuration (release or debug)
487rem %2 - Build Type (static or shared)
488rem %3 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
489rem
490:install
491  setlocal
492
493  if "%1" == "" exit /B 1
494  if "%2" == "" exit /B 1
495  if "%3" == "" exit /B 1
496
497  rem Copy the generated files to our directory structure
498  if "%3" == "TRUE" (
499    rem There's no actual installation for legacy OpenSSL, the files are copied
500    rem from the build dir (for legacy this is same as source dir) to the final
501    rem location.
502    cd /d "%SOURCE_PATH%" || (echo Error: Failed cd source & exit /B 1)
503    if "%1" == "debug" (
504      if "%2" == "static" (
505        rem Move the output directories
506        if exist "%OUTDIR%\LIB Debug" (
507          copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
508          rd out32.dbg /s /q
509        ) else (
510          move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
511        )
512
513        rem Move the PDB files
514        move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
515
516        rem Remove the intermediate directories
517        rd tmp32.dbg /s /q
518      ) else if "%2" == "shared" (
519        if exist "%OUTDIR%\DLL Debug" (
520          copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
521          rd out32dll.dbg /s /q
522        ) else (
523          move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
524        )
525
526        rem Move the PDB files
527        move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
528
529        rem Remove the intermediate directories
530        rd tmp32dll.dbg /s /q
531      ) else (
532        exit /B 1
533      )
534    ) else if "%1" == "release" (
535      if "%2" == "static" (
536        rem Move the output directories
537        if exist "%OUTDIR%\LIB Release" (
538          copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
539          rd out32 /s /q
540        ) else (
541          move out32 "%OUTDIR%\LIB Release" 1>nul
542        )
543
544        rem Move the PDB files
545        move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
546
547        rem Remove the intermediate directories
548        rd tmp32 /s /q
549      ) else if "%2" == "shared" (
550        if exist "%OUTDIR%\DLL Release" (
551          copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
552          rd out32dll /s /q
553        ) else (
554          move out32dll "%OUTDIR%\DLL Release" 1>nul
555        )
556
557        rem Move the PDB files
558        move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
559
560        rem Remove the intermediate directories
561        rd tmp32dll /s /q
562      ) else (
563        exit /B 1
564      )
565    )
566  ) else if "%3" == "FALSE" (
567    cd /d "%TMP_BUILD_PATH%" || (echo Error: Failed cd build & exit /B 1)
568
569    rem Perform the installation
570    nmake install_sw
571
572    cd /d "%SOURCE_PATH%" || (echo Error: Failed cd source & exit /B 1)
573
574    rem Move the output directories
575    if "%1" == "debug" (
576      if "%2" == "static" (
577        if not exist "%OUTDIR%\LIB Debug" (
578          mkdir "%OUTDIR%\LIB Debug" 1>nul
579        )
580
581        move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\LIB Debug" 1>nul
582        move "%TMP_INSTALL_PATH%\lib\*.pdb" "%OUTDIR%\LIB Debug" 1>nul
583        move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\LIB Debug" 1>nul
584        move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\LIB Debug" 1>nul
585        xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\LIB Debug\include" 1>nul
586      ) else if "%2" == "shared" (
587        if not exist "%OUTDIR%\DLL Debug" (
588          mkdir "%OUTDIR%\DLL Debug" 1>nul
589        )
590
591        move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\DLL Debug" 1>nul
592        if exist "%TMP_INSTALL_PATH%\lib\engines-3" (
593          move "%TMP_INSTALL_PATH%\lib\engines-3\*.dll" "%OUTDIR%\DLL Debug" 1>nul
594          move "%TMP_INSTALL_PATH%\lib\engines-3\*.pdb" "%OUTDIR%\DLL Debug" 1>nul
595        ) else if exist "%TMP_INSTALL_PATH%\lib\engines-1_1" (
596          move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.dll" "%OUTDIR%\DLL Debug" 1>nul
597          move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.pdb" "%OUTDIR%\DLL Debug" 1>nul
598        )
599        move "%TMP_INSTALL_PATH%\bin\*.dll" "%OUTDIR%\DLL Debug" 1>nul
600        move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\DLL Debug" 1>nul
601        move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\DLL Debug" 1>nul
602        xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\DLL Debug\include" 1>nul
603      ) else (
604        exit /B 1
605      )
606    ) else if "%1" == "release" (
607      if "%2" == "static" (
608        if not exist "%OUTDIR%\LIB Release" (
609          mkdir "%OUTDIR%\LIB Release" 1>nul
610        )
611
612        move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\LIB Release" 1>nul
613        move "%TMP_INSTALL_PATH%\lib\*.pdb" "%OUTDIR%\LIB Release" 1>nul
614        move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\LIB Release" 1>nul
615        move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\LIB Release" 1>nul
616        xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\LIB Release\include" 1>nul
617      ) else if "%2" == "shared" (
618        if not exist "%OUTDIR%\DLL Release" (
619          mkdir "%OUTDIR%\DLL Release" 1>nul
620        )
621
622        move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\DLL Release" 1>nul
623        if exist "%TMP_INSTALL_PATH%\lib\engines-3" (
624          move "%TMP_INSTALL_PATH%\lib\engines-3\*.dll" "%OUTDIR%\DLL Release" 1>nul
625          move "%TMP_INSTALL_PATH%\lib\engines-3\*.pdb" "%OUTDIR%\DLL Release" 1>nul
626        ) else if exist "%TMP_INSTALL_PATH%\lib\engines-1_1" (
627          move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.dll" "%OUTDIR%\DLL Release" 1>nul
628          move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.pdb" "%OUTDIR%\DLL Release" 1>nul
629        )
630        move "%TMP_INSTALL_PATH%\bin\*.dll" "%OUTDIR%\DLL Release" 1>nul
631        move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\DLL Release" 1>nul
632        move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\DLL Release" 1>nul
633        xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\DLL Release\include" 1>nul
634      ) else (
635        exit /B 1
636      )
637    ) else (
638      exit /B 1
639    )
640
641    rem Remove the output directories
642    if not "%SOURCE_PATH%" == "%TMP_BUILD_PATH%" (
643      rd "%TMP_BUILD_PATH%" /s /q
644    )
645    if not "%SOURCE_PATH%" == "%TMP_INSTALL_PATH%" (
646      rd "%TMP_INSTALL_PATH%" /s /q
647    )
648  ) else (
649    exit /B 1
650  )
651
652  exit /B 0
653
654:syntax
655  rem Display the help
656  echo.
657  echo Usage: build-openssl ^<compiler^> [platform] [configuration] [directory] [-VSpath] ["VSpath"] [-perlpath] ["perlpath"]
658  echo.
659  echo Compiler:
660  echo.
661  echo vc10      - Use Visual Studio 2010
662  echo vc11      - Use Visual Studio 2012
663  echo vc12      - Use Visual Studio 2013
664  echo vc14      - Use Visual Studio 2015
665  echo vc14.1    - Use Visual Studio 2017
666  echo vc14.2    - Use Visual Studio 2019
667  echo vc14.3    - Use Visual Studio 2022
668  echo.
669  echo Platform:
670  echo.
671  echo x86       - Perform a 32-bit build
672  echo x64       - Perform a 64-bit build
673  echo.
674  echo Configuration:
675  echo.
676  echo debug     - Perform a debug build
677  echo release   - Perform a release build
678  echo.
679  echo Other:
680  echo.
681  echo directory - Specifies the OpenSSL source directory
682  echo.
683  echo -VSpath - Specify the custom VS path if Visual Studio is not located at
684  echo           "C:\<ProgramFiles>\Microsoft Visual Studio <version>"
685  echo           For e.g. -VSpath "C:\apps\MVS14"
686  echo.
687  echo -perlpath - Specify the custom perl root path if perl is not located at
688  echo             "C:\Perl" and it is a portable copy of perl and not
689  echo             installed on the win system.
690  echo             For e.g. -perlpath "D:\strawberry-perl-5.24.3.1-64bit-portable"
691  goto error
692
693:unknown
694  echo.
695  echo Error: Unknown argument '%1'
696  goto error
697
698:nodos
699  echo.
700  echo Error: Only a Windows NT based Operating System is supported
701  goto error
702
703:nopf
704  echo.
705  echo Error: Cannot obtain the directory for Program Files
706  goto error
707
708:novc
709  echo.
710  echo Error: %VC_DESC% is not installed
711  echo Error: Please check whether Visual compiler is installed at the path "%ABS_VC_PATH%"
712  echo Error: Please provide proper VS Path by using -VSpath
713  goto error
714
715:noperl
716  echo.
717  echo Error: Perl is not installed
718  echo Error: Please check whether Perl is installed or it is at location "C:\Perl"
719  echo Error: If Perl is portable please provide perl root path by using -perlpath
720  goto error
721
722:nox64
723  echo.
724  echo Error: %VC_DESC% does not support 64-bit builds
725  goto error
726
727:noopenssl
728  echo.
729  echo Error: Cannot locate OpenSSL source directory
730  goto error
731
732:error
733  if "%OS%" == "Windows_NT" endlocal
734  exit /B 1
735
736:success
737  cd /d "%SAVED_PATH%"
738  endlocal
739  exit /B 0
740