@@ -21,6 +21,10 @@ pub fn build(b: *std.Build) void {
21
21
22
22
const crypto_choice = b .option (CryptoBackend , "crypto-backend" , "Crypto backend: auto|openssl|mbedtls|libgcrypt|wincng" ) orelse .auto ;
23
23
const zlib = b .option (bool , "zlib" , "Enable SSH payload compression (links zlib)" ) orelse false ;
24
+ const mbedtls_linkage = b .option (std .builtin .LinkMode , "mbedtls-linkage" , "static|dynamic" ) orelse .static ;
25
+ const openssl_linkage = b .option (std .builtin .LinkMode , "openssl-linkage" , "static|dynamic" ) orelse .static ;
26
+ const wincng_linkage = b .option (std .builtin .LinkMode , "wincng-linkage" , "static|dynamic" ) orelse .static ;
27
+ const gcrypt_linkage = b .option (std .builtin .LinkMode , "gcrypt-linkage" , "static|dynamic" ) orelse .static ;
24
28
25
29
const is_windows = target .result .os .tag == .windows ;
26
30
const mbedtls = crypto_choice == .mbedtls ;
@@ -70,27 +74,26 @@ pub fn build(b: *std.Build) void {
70
74
71
75
if (mbedtls ) {
72
76
ssh2_lib .root_module .addCMacro ("LIBSSH2_MBEDTLS" , "1" );
73
- ssh2_lib .linkSystemLibrary ("mbedtls" );
74
- ssh2_lib .linkSystemLibrary ("mbedcrypto" );
75
- ssh2_lib .linkSystemLibrary ("mbedx509" );
77
+ ssh2_lib .linkSystemLibrary2 ("mbedtls" , .{ . preferred_link_mode = mbedtls_linkage } );
78
+ ssh2_lib .linkSystemLibrary2 ("mbedcrypto" , .{ . preferred_link_mode = mbedtls_linkage } );
79
+ ssh2_lib .linkSystemLibrary2 ("mbedx509" , .{ . preferred_link_mode = mbedtls_linkage } );
76
80
}
77
81
78
82
if (openssl ) {
79
83
ssh2_lib .root_module .addCMacro ("LIBSSH2_OPENSSL" , "1" );
80
- ssh2_lib .linkSystemLibrary ("ssl" );
81
- ssh2_lib .linkSystemLibrary ("crypto" );
84
+ ssh2_lib .linkSystemLibrary2 ("ssl" , .{ . preferred_link_mode = openssl_linkage } );
85
+ ssh2_lib .linkSystemLibrary2 ("crypto" , .{ . preferred_link_mode = openssl_linkage } );
82
86
}
83
87
84
88
if (wincng ) {
85
89
ssh2_lib .root_module .addCMacro ("LIBSSH2_WINCNG" , "1" );
86
- // Windows system libs (zig handles names)
87
- ssh2_lib .linkSystemLibrary ("bcrypt" );
88
- ssh2_lib .linkSystemLibrary ("ncrypt" );
90
+ ssh2_lib .linkSystemLibrary2 ("bcrypt" , .{ .preferred_link_mode = wincng_linkage });
91
+ ssh2_lib .linkSystemLibrary2 ("ncrypt" , .{ .preferred_link_mode = wincng_linkage });
89
92
}
90
93
91
94
if (libgcrypt ) {
92
95
ssh2_lib .root_module .addCMacro ("LIBSSH2_LIBGCRYPT" , "1" );
93
- ssh2_lib .linkSystemLibrary ("gcrypt" );
96
+ ssh2_lib .linkSystemLibrary2 ("gcrypt" , .{ . preferred_link_mode = gcrypt_linkage } );
94
97
}
95
98
96
99
if (zlib ) {
0 commit comments