-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_openssl.ps1
98 lines (76 loc) · 2.33 KB
/
build_openssl.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#requires -version 3.0
# Author: Jon Maken
# License: 3-clause BSD
# Revision: 2021-08-24 15:25:14 -0600
param(
[parameter(Mandatory=$true,
Position=0,
HelpMessage='OpenSSL version to build (eg - 1.1.1l).')]
[validateset('1.1.1l')]
[alias('v')]
[string] $version,
[parameter(HelpMessage='Perform a 64-bit build')]
[switch] $x64,
[parameter(HelpMessage='Create a static CLI exe')]
[switch] $cli,
[parameter(HelpMessage='Path to zlib dev libraries root directory')]
[alias('with-zlib-dir')]
[string] $ZLIB_DIR = 'C:/devlibs/zlib/x86/1.2.11'
)
$libname = 'openssl'
$source = "${libname}-${version}.tar.gz"
$build_name = "${libname}-${version}"
$repo_root = 'https://www.openssl.org/source/'
$archive = "${repo_root}${source}"
$hash_uri = "https://raw.github.com/jonforums/buildlets/master/hashery/${libname}.sha1"
if ($x64) { $mingw_flavor = 'mingw64' } else { $mingw_flavor = 'mingw' }
# source the buildlet library
. "$PWD\buildlet_utils.ps1"
# download source archive
Fetch-Archive
# download hash data and validate source archive
Validate-Archive
# extract
Extract-Archive
# patch, configure, build, archive
Push-Location "${build_src_dir}"
# activate toolchain
Activate-Toolchain {
$ZLIB_DIR = $ZLIB_DIR.Replace('\', '/')
$env:CPATH = "$ZLIB_DIR/include"
# FIXME more cleanly integrate with existing Configure script invocation
$env:CC = 'gcc -static-libgcc'
}
# configure
Configure-Build {
if ($cli) {
Write-Status 'building openssl-cli.exe static CLI executable'
$env:CFLAGS = "-static"
perl Configure $mingw_flavor zlib no-shared --prefix="$install_dir" --openssldir='C:/tools/ssl' | Out-Null
} else {
perl Configure $mingw_flavor zlib-dynamic shared --prefix="$install_dir" | Out-Null
}
}
# build
New-Build {
sh -c "make" | Out-Null
}
# install
sh -c "make install_sw" | Out-Null
# stage
Stage-Build {
if ($cli) {
mv "$install_dir/bin/${libname}.exe" "$install_dir/${libname}-cli.exe" | Out-Null
strip --strip-unneeded "$install_dir/${libname}-cli.exe" | Out-Null
rm "$install_dir/bin", "$install_dir/include", "$install_dir/lib" -recurse -force | Out-Null
}
}
# archive
if ($cli) {
Archive-Build -variant 'static-cli'
} else {
Archive-Build
}
Pop-Location
# cleanup
Clean-Build