@@ -114,6 +114,34 @@ sub copyFile
114
114
return ;
115
115
}
116
116
117
+ # Fetch version of OpenSSL based on a parsing of the command shipped with
118
+ # the installer this build is linking to. This returns as result an array
119
+ # made of the three first digits of the OpenSSL version, which is enough
120
+ # to decide which options to apply depending on the version of OpenSSL
121
+ # linking with.
122
+ sub GetOpenSSLVersion
123
+ {
124
+ my $self = shift ;
125
+
126
+ # Attempt to get OpenSSL version and location. This assumes that
127
+ # openssl.exe is in the specified directory.
128
+ my $opensslcmd =
129
+ $self -> {options }-> {openssl } . " \\ bin\\ openssl.exe version 2>&1" ;
130
+ my $sslout = ` $opensslcmd ` ;
131
+
132
+ $? >> 8 == 0
133
+ or croak
134
+ " Unable to determine OpenSSL version: The openssl.exe command wasn't found." ;
135
+
136
+ if ($sslout =~ / (\d +)\. (\d +)\. (\d +)(\D )/m )
137
+ {
138
+ return ($1 , $2 , $3 );
139
+ }
140
+
141
+ croak
142
+ " Unable to determine OpenSSL version: The openssl.exe version could not be determined." ;
143
+ }
144
+
117
145
sub GenerateFiles
118
146
{
119
147
my $self = shift ;
@@ -168,10 +196,9 @@ sub GenerateFiles
168
196
print $o " #ifndef IGNORE_CONFIGURED_SETTINGS\n " ;
169
197
print $o " #define USE_ASSERT_CHECKING 1\n "
170
198
if ($self -> {options }-> {asserts });
171
- print $o " #define USE_LDAP 1\n " if ($self -> {options }-> {ldap });
172
- print $o " #define HAVE_LIBZ 1\n " if ($self -> {options }-> {zlib });
173
- print $o " #define USE_OPENSSL 1\n " if ($self -> {options }-> {openssl });
174
- print $o " #define ENABLE_NLS 1\n " if ($self -> {options }-> {nls });
199
+ print $o " #define USE_LDAP 1\n " if ($self -> {options }-> {ldap });
200
+ print $o " #define HAVE_LIBZ 1\n " if ($self -> {options }-> {zlib });
201
+ print $o " #define ENABLE_NLS 1\n " if ($self -> {options }-> {nls });
175
202
176
203
print $o " #define BLCKSZ " , 1024 * $self -> {options }-> {blocksize },
177
204
" \n " ;
@@ -219,6 +246,21 @@ sub GenerateFiles
219
246
{
220
247
print $o " #define ENABLE_GSS 1\n " ;
221
248
}
249
+ if ($self -> {options }-> {openssl })
250
+ {
251
+ print $o " #define USE_OPENSSL 1\n " ;
252
+
253
+ my ($digit1 , $digit2 , $digit3 ) = $self -> GetOpenSSLVersion();
254
+
255
+ # More symbols are needed with OpenSSL 1.1.0 and above.
256
+ if ($digit1 >= ' 1' && $digit2 >= ' 1' && $digit3 >= ' 0' )
257
+ {
258
+ print $o " #define HAVE_ASN1_STRING_GET0_DATA 1\n " ;
259
+ print $o " #define HAVE_BIO_GET_DATA 1\n " ;
260
+ print $o " #define HAVE_BIO_METH_NEW 1\n " ;
261
+ print $o " #define HAVE_OPENSSL_INIT_SSL 1\n " ;
262
+ }
263
+ }
222
264
if ($self -> {options }-> {icu })
223
265
{
224
266
print $o " #define USE_ICU 1\n " ;
@@ -613,21 +655,70 @@ sub AddProject
613
655
if ($self -> {options }-> {openssl })
614
656
{
615
657
$proj -> AddIncludeDir($self -> {options }-> {openssl } . ' \include' );
616
- if (-e " $self ->{options}->{openssl}/lib/VC/ssleay32MD.lib" )
658
+ my ($digit1 , $digit2 , $digit3 ) = $self -> GetOpenSSLVersion();
659
+
660
+ # Starting at version 1.1.0 the OpenSSL installers have
661
+ # changed their library names from:
662
+ # - libeay to libcrypto
663
+ # - ssleay to libssl
664
+ if ($digit1 >= ' 1' && $digit2 >= ' 1' && $digit3 >= ' 0' )
617
665
{
618
- $proj -> AddLibrary(
619
- $self -> {options }-> {openssl } . ' \lib\VC\ssleay32.lib' , 1);
620
- $proj -> AddLibrary(
621
- $self -> {options }-> {openssl } . ' \lib\VC\libeay32.lib' , 1);
666
+ my $dbgsuffix ;
667
+ my $libsslpath ;
668
+ my $libcryptopath ;
669
+
670
+ # The format name of the libraries is slightly
671
+ # different between the Win32 and Win64 platform, so
672
+ # adapt.
673
+ if (-e " $self ->{options}->{openssl}/lib/VC/sslcrypto32MD.lib" )
674
+ {
675
+ # Win32 here, with a debugging library set.
676
+ $dbgsuffix = 1;
677
+ $libsslpath = ' \lib\VC\libssl32.lib' ;
678
+ $libcryptopath = ' \lib\VC\libcrypto32.lib' ;
679
+ }
680
+ elsif (-e " $self ->{options}->{openssl}/lib/VC/sslcrypto64MD.lib" )
681
+ {
682
+ # Win64 here, with a debugging library set.
683
+ $dbgsuffix = 1;
684
+ $libsslpath = ' \lib\VC\libssl64.lib' ;
685
+ $libcryptopath = ' \lib\VC\libcrypto64.lib' ;
686
+ }
687
+ else
688
+ {
689
+ # On both Win32 and Win64 the same library
690
+ # names are used without a debugging context.
691
+ $dbgsuffix = 0;
692
+ $libsslpath = ' \lib\libssl.lib' ;
693
+ $libcryptopath = ' \lib\libcrypto.lib' ;
694
+ }
695
+
696
+ $proj -> AddLibrary($self -> {options }-> {openssl } . $libsslpath ,
697
+ $dbgsuffix );
698
+ $proj -> AddLibrary($self -> {options }-> {openssl } . $libcryptopath ,
699
+ $dbgsuffix );
622
700
}
623
701
else
624
702
{
625
- # We don't expect the config-specific library to be here,
626
- # so don't ask for it in last parameter
627
- $proj -> AddLibrary(
628
- $self -> {options }-> {openssl } . ' \lib\ssleay32.lib' , 0);
629
- $proj -> AddLibrary(
630
- $self -> {options }-> {openssl } . ' \lib\libeay32.lib' , 0);
703
+ # Choose which set of libraries to use depending on if
704
+ # debugging libraries are in place in the installer.
705
+ if (-e " $self ->{options}->{openssl}/lib/VC/ssleay32MD.lib" )
706
+ {
707
+ $proj -> AddLibrary(
708
+ $self -> {options }-> {openssl } . ' \lib\VC\ssleay32.lib' , 1);
709
+ $proj -> AddLibrary(
710
+ $self -> {options }-> {openssl } . ' \lib\VC\libeay32.lib' , 1);
711
+ }
712
+ else
713
+ {
714
+ # We don't expect the config-specific library
715
+ # to be here, so don't ask for it in last
716
+ # parameter.
717
+ $proj -> AddLibrary(
718
+ $self -> {options }-> {openssl } . ' \lib\ssleay32.lib' , 0);
719
+ $proj -> AddLibrary(
720
+ $self -> {options }-> {openssl } . ' \lib\libeay32.lib' , 0);
721
+ }
631
722
}
632
723
}
633
724
if ($self -> {options }-> {nls })
0 commit comments