@@ -118,6 +118,34 @@ sub copyFile
118
118
return ;
119
119
}
120
120
121
+ # Fetch version of OpenSSL based on a parsing of the command shipped with
122
+ # the installer this build is linking to. This returns as result an array
123
+ # made of the three first digits of the OpenSSL version, which is enough
124
+ # to decide which options to apply depending on the version of OpenSSL
125
+ # linking with.
126
+ sub GetOpenSSLVersion
127
+ {
128
+ my $self =shift ;
129
+
130
+ # Attempt to get OpenSSL version and location. This assumes that
131
+ # openssl.exe is in the specified directory.
132
+ my $opensslcmd =
133
+ $self -> {options }-> {openssl } ." \\ bin\\ openssl.exe version 2>&1" ;
134
+ my $sslout =` $opensslcmd ` ;
135
+
136
+ $? >> 8 == 0
137
+ or croak
138
+ " Unable to determine OpenSSL version: The openssl.exe command wasn't found." ;
139
+
140
+ if ($sslout =~/ (\d +)\. (\d +)\. (\d +)(\D )/m )
141
+ {
142
+ return ($1 ,$2 ,$3 );
143
+ }
144
+
145
+ croak
146
+ " Unable to determine OpenSSL version: The openssl.exe version could not be determined." ;
147
+ }
148
+
121
149
sub GenerateFiles
122
150
{
123
151
my $self =shift ;
@@ -172,10 +200,9 @@ sub GenerateFiles
172
200
print $o " #ifndef IGNORE_CONFIGURED_SETTINGS\n " ;
173
201
print $o " #define USE_ASSERT_CHECKING 1\n "
174
202
if ($self -> {options }-> {asserts });
175
- print $o " #define USE_LDAP 1\n " if ($self -> {options }-> {ldap });
176
- print $o " #define HAVE_LIBZ 1\n " if ($self -> {options }-> {zlib });
177
- print $o " #define USE_OPENSSL 1\n " if ($self -> {options }-> {openssl });
178
- print $o " #define ENABLE_NLS 1\n " if ($self -> {options }-> {nls });
203
+ print $o " #define USE_LDAP 1\n " if ($self -> {options }-> {ldap });
204
+ print $o " #define HAVE_LIBZ 1\n " if ($self -> {options }-> {zlib });
205
+ print $o " #define ENABLE_NLS 1\n " if ($self -> {options }-> {nls });
179
206
180
207
print $o " #define BLCKSZ" , 1024 *$self -> {options }-> {blocksize },
181
208
" \n " ;
@@ -223,6 +250,21 @@ sub GenerateFiles
223
250
{
224
251
print $o " #define ENABLE_GSS 1\n " ;
225
252
}
253
+ if ($self -> {options }-> {openssl })
254
+ {
255
+ print $o " #define USE_OPENSSL 1\n " ;
256
+
257
+ my ($digit1 ,$digit2 ,$digit3 ) =$self -> GetOpenSSLVersion();
258
+
259
+ # More symbols are needed with OpenSSL 1.1.0 and above.
260
+ if ($digit1 >=' 1' &&$digit2 >=' 1' &&$digit3 >=' 0' )
261
+ {
262
+ print $o " #define HAVE_ASN1_STRING_GET0_DATA 1\n " ;
263
+ print $o " #define HAVE_BIO_GET_DATA 1\n " ;
264
+ print $o " #define HAVE_BIO_METH_NEW 1\n " ;
265
+ print $o " #define HAVE_OPENSSL_INIT_SSL 1\n " ;
266
+ }
267
+ }
226
268
if ($self -> {options }-> {icu })
227
269
{
228
270
print $o " #define USE_ICU 1\n " ;
@@ -579,21 +621,70 @@ sub AddProject
579
621
if ($self -> {options }-> {openssl })
580
622
{
581
623
$proj -> AddIncludeDir($self -> {options }-> {openssl } .' \include' );
582
- if (-e " $self ->{options}->{openssl}/lib/VC/ssleay32MD.lib" )
624
+ my ($digit1 ,$digit2 ,$digit3 ) =$self -> GetOpenSSLVersion();
625
+
626
+ # Starting at version 1.1.0 the OpenSSL installers have
627
+ # changed their library names from:
628
+ # - libeay to libcrypto
629
+ # - ssleay to libssl
630
+ if ($digit1 >=' 1' &&$digit2 >=' 1' &&$digit3 >=' 0' )
583
631
{
584
- $proj -> AddLibrary(
585
- $self -> {options }-> {openssl } .' \lib\VC\ssleay32.lib' , 1);
586
- $proj -> AddLibrary(
587
- $self -> {options }-> {openssl } .' \lib\VC\libeay32.lib' , 1);
632
+ my $dbgsuffix ;
633
+ my $libsslpath ;
634
+ my $libcryptopath ;
635
+
636
+ # The format name of the libraries is slightly
637
+ # different between the Win32 and Win64 platform, so
638
+ # adapt.
639
+ if (-e " $self ->{options}->{openssl}/lib/VC/sslcrypto32MD.lib" )
640
+ {
641
+ # Win32 here, with a debugging library set.
642
+ $dbgsuffix = 1;
643
+ $libsslpath =' \lib\VC\libssl32.lib' ;
644
+ $libcryptopath =' \lib\VC\libcrypto32.lib' ;
645
+ }
646
+ elsif (-e " $self ->{options}->{openssl}/lib/VC/sslcrypto64MD.lib" )
647
+ {
648
+ # Win64 here, with a debugging library set.
649
+ $dbgsuffix = 1;
650
+ $libsslpath =' \lib\VC\libssl64.lib' ;
651
+ $libcryptopath =' \lib\VC\libcrypto64.lib' ;
652
+ }
653
+ else
654
+ {
655
+ # On both Win32 and Win64 the same library
656
+ # names are used without a debugging context.
657
+ $dbgsuffix = 0;
658
+ $libsslpath =' \lib\libssl.lib' ;
659
+ $libcryptopath =' \lib\libcrypto.lib' ;
660
+ }
661
+
662
+ $proj -> AddLibrary($self -> {options }-> {openssl } .$libsslpath ,
663
+ $dbgsuffix );
664
+ $proj -> AddLibrary($self -> {options }-> {openssl } .$libcryptopath ,
665
+ $dbgsuffix );
588
666
}
589
667
else
590
668
{
591
- # We don't expect the config-specific library to be here,
592
- # so don't ask for it in last parameter
593
- $proj -> AddLibrary(
594
- $self -> {options }-> {openssl } .' \lib\ssleay32.lib' , 0);
595
- $proj -> AddLibrary(
596
- $self -> {options }-> {openssl } .' \lib\libeay32.lib' , 0);
669
+ # Choose which set of libraries to use depending on if
670
+ # debugging libraries are in place in the installer.
671
+ if (-e " $self ->{options}->{openssl}/lib/VC/ssleay32MD.lib" )
672
+ {
673
+ $proj -> AddLibrary(
674
+ $self -> {options }-> {openssl } .' \lib\VC\ssleay32.lib' , 1);
675
+ $proj -> AddLibrary(
676
+ $self -> {options }-> {openssl } .' \lib\VC\libeay32.lib' , 1);
677
+ }
678
+ else
679
+ {
680
+ # We don't expect the config-specific library
681
+ # to be here, so don't ask for it in last
682
+ # parameter.
683
+ $proj -> AddLibrary(
684
+ $self -> {options }-> {openssl } .' \lib\ssleay32.lib' , 0);
685
+ $proj -> AddLibrary(
686
+ $self -> {options }-> {openssl } .' \lib\libeay32.lib' , 0);
687
+ }
597
688
}
598
689
}
599
690
if ($self -> {options }-> {nls })