@@ -47,27 +47,24 @@ VERSION = 1.2.0 ;
47
47
48
48
# rule for linking the correct libraries depending
49
49
# on features and target-os
50
- rule linking ( properties * )
50
+ rule link-openssl ( properties * )
51
51
{
52
52
local result ;
53
53
54
54
# openssl libraries, if enabled
55
55
# exclude gcc from a regular windows build to make mingw
56
56
# link against the regular unix library name
57
- if <crypto>openssl in $(properties)
57
+ if <openssl-version>pre1.1 in $(properties)
58
+ && <target-os>windows in $(properties)
59
+ && ! <toolset>gcc in $(properties)
58
60
{
59
- if <openssl-version>pre1.1 in $(properties)
60
- && <target-os>windows in $(properties)
61
- && ! <toolset>gcc in $(properties)
62
- {
63
- result += <library>ssleay32 <library>libeay32 ;
64
- }
65
- else
66
- {
67
- # on windows the library names were changed to be in line with other
68
- # system starting with OpenSSL 1.1
69
- result += <library>crypto <library>ssl ;
70
- }
61
+ result += <library>ssleay32 <library>libeay32 ;
62
+ }
63
+ else
64
+ {
65
+ # on windows the library names were changed to be in line with other
66
+ # system starting with OpenSSL 1.1
67
+ result += <library>crypto <library>ssl ;
71
68
}
72
69
73
70
if <crypto>libcrypto in $(properties)
@@ -88,9 +85,7 @@ rule linking ( properties * )
88
85
}
89
86
90
87
# windows needs some more libraries when using openSSL
91
- if ( <crypto>openssl in $(properties)
92
- || <crypto>libcrypto in $(propertes) )
93
- && <target-os>windows in $(properties)
88
+ if <target-os>windows in $(properties)
94
89
&& ! <toolset>gcc in $(properties)
95
90
{
96
91
result += <library>advapi32
@@ -99,7 +94,13 @@ rule linking ( properties * )
99
94
<library>gdi32
100
95
;
101
96
}
97
+ echo "link openssl = " $(result) ;
98
+ return $(result) ;
99
+ }
102
100
101
+ rule linking ( properties * )
102
+ {
103
+ local result ;
103
104
if <simulator>on in $(properties)
104
105
{
105
106
result += <library>/libsimulator//simulator ;
@@ -375,7 +376,7 @@ rule default-build ( properties * )
375
376
return $(result) ;
376
377
}
377
378
378
- rule tag ( name : type ? : property-set )
379
+ rule tag ( name : type ? : property-set )
379
380
{
380
381
name = [ virtual-target.add-prefix-and-suffix $(name) : $(type) : $(property-set) ] ;
381
382
@@ -388,6 +389,78 @@ rule tag ( name : type ? : property-set )
388
389
return $(name) ;
389
390
}
390
391
392
+ # the search path to pick up the openssl libraries from. This is the <search>
393
+ # property of those libraries
394
+ rule openssl-lib-path ( properties * )
395
+ {
396
+ local OPENSSL_LIB = [ feature.get-values <openssl-lib> : $(properties) ] ;
397
+
398
+ if <target-os>darwin in $(properties) && $(OPENSSL_LIB) = ""
399
+ {
400
+ # on macOS, default to pick up openssl from the homebrew installation
401
+ # brew install openssl
402
+ OPENSSL_LIB = /usr/local/opt/openssl/lib ;
403
+ }
404
+ else if <target-os>windows in $(properties)
405
+ && <toolset>gcc in $(properties)
406
+ && $(OPENSSL_LIB) = ""
407
+ {
408
+ # on mingw, assume openssl is installed in c:\OpenSSL-Win32 by default
409
+ OPENSSL_LIB = c:\\OpenSSL-Win32\\lib ;
410
+ }
411
+ else if <target-os>windows in $(properties) && $(OPENSSL_LIB) = ""
412
+ {
413
+ # on windows, just assume openssl is installed to c:\openssl
414
+ if <address-model>64 in $(properties)
415
+ { OPENSSL_LIB = c:\\openssl\\lib64 ; }
416
+ else
417
+ { OPENSSL_LIB = c:\\openssl\\lib ; }
418
+ }
419
+
420
+ local result ;
421
+ result += <search>$(OPENSSL_LIB) ;
422
+ echo "openssl-lib-path = " $(result) ;
423
+ return $(result) ;
424
+ }
425
+
426
+ # the include path to pick up openssl headers from. This is the
427
+ # usage-requirement for the openssl-related libraries
428
+ rule openssl-include-path ( properties * )
429
+ {
430
+ local OPENSSL_INCLUDE = [ feature.get-values <openssl-include> : $(properties) ] ;
431
+
432
+ if <target-os>darwin in $(properties) && $(OPENSSL_INCLUDE) = ""
433
+ {
434
+ # on macOS, default to pick up openssl from the homebrew installation
435
+ # brew install openssl
436
+ OPENSSL_INCLUDE = /usr/local/opt/openssl/include ;
437
+ }
438
+ else if <target-os>windows in $(properties)
439
+ && <toolset>gcc in $(properties)
440
+ && $(OPENSSL_INCLUDE) = ""
441
+ {
442
+ # on mingw, assume openssl is installed in c:\OpenSSL-Win32 by default
443
+ OPENSSL_INCLUDE = c:\\OpenSSL-Win32\\include ;
444
+ }
445
+ else if <target-os>windows in $(properties) && $(OPENSSL_INCLUDE) = ""
446
+ {
447
+ # on windows, just assume openssl is installed to c:\openssl
448
+ # not sure if there's a better way to find out where it may be
449
+ if <address-model>64 in $(properties)
450
+ { OPENSSL_INCLUDE = c:\\openssl\\include64 ; }
451
+ else
452
+ { OPENSSL_INCLUDE = c:\\openssl\\include ; }
453
+ }
454
+
455
+ local result ;
456
+ result += <include>$(OPENSSL_INCLUDE) ;
457
+ echo "openssl-include-path = " $(result) ;
458
+ return $(result) ;
459
+ }
460
+
461
+ feature openssl-lib : : free path ;
462
+ feature openssl-include : : free path ;
463
+
391
464
feature ipv6 : on off : composite propagated link-incompatible ;
392
465
feature.compose <ipv6>off : <define>TORRENT_USE_IPV6=0 ;
393
466
@@ -515,9 +588,12 @@ variant test_arm : debug
515
588
<export-extra>on <asserts>on
516
589
;
517
590
591
+ lib crypto : : <name>crypto <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
592
+ lib ssl : : <name>ssl <use>crypto <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
593
+
518
594
# required for openssl on windows
519
- lib ssleay32 : : <name>ssleay32 ;
520
- lib libeay32 : : <name>libeay32 ;
595
+ lib ssleay32 : : <name>ssleay32 <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
596
+ lib libeay32 : : <name>libeay32 <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
521
597
lib advapi32 : : <name>advapi32 ;
522
598
lib user32 : : <name>user32 ;
523
599
lib shell32 : : <name>shell32 ;
@@ -534,12 +610,7 @@ lib libiconv : : <name>iconv <link>shared <search>/usr/local/lib ;
534
610
# openssl on linux/bsd etc.
535
611
lib gcrypt : : <name>gcrypt <link>shared <search>/opt/local/lib ;
536
612
537
- # pick up openssl on macos from brew
538
- lib crypto : : <name>crypto <target-os>darwin <search>/usr/local/opt/openssl/lib : <link>shared : <include>/usr/local/opt/openssl/include ;
539
- lib ssl : : <name>ssl <use>crypto <target-os>darwin <search>/usr/local/opt/openssl/lib : <link>shared : <include>/usr/local/opt/openssl/include ;
540
-
541
- lib crypto : : <name>crypto : <link>shared ;
542
- lib ssl : : <name>ssl <use>crypto : <link>shared ;
613
+ alias openssl-libraries : : : : <conditional>@link-openssl ;
543
614
544
615
lib libsocket : : <use>libnsl <name>socket <link>shared <search>/usr/sfw/lib <link>shared ;
545
616
lib libnsl : : <name>nsl <link>shared <search>/usr/sfw/lib <link>shared ;
@@ -754,6 +825,8 @@ lib torrent
754
825
<link>shared:<define>TORRENT_BUILDING_SHARED
755
826
<define>BOOST_NO_DEPRECATED
756
827
<link>shared:<define>BOOST_SYSTEM_SOURCE
828
+ <crypto>openssl:<library>openssl-libraries
829
+ <crypto>libcrypto:<library>openssl-libraries
757
830
758
831
<dht>on:<source>src/kademlia/$(KADEMLIA_SOURCES).cpp
759
832
<dht>on:<source>ed25519/src/$(ED25519_SOURCES).cpp
0 commit comments