2 package Module::Install::PRIVATE::Net::SSLeay;
5 use Module::Install::Base;
11 use vars qw{$VERSION @ISA};
14 @ISA = qw{Module::Install::Base};
17 # Define this to one if you want to link the openssl libraries statically into
18 # the Net-SSLeay loadable object on Windows
19 my $win_link_statically = 0;
24 $self->requires_external_cc;
26 my $prefix = $self->find_openssl_prefix;
27 my $exec = $self->find_openssl_exec($prefix);
31 *** Could not find OpenSSL
32 If it's already installed, please set the OPENSSL_PREFIX environment
33 variable accordingly. If it isn't installed yet, get the latest version
34 from http://www.openssl.org/.
38 $self->check_openssl_version($prefix, $exec);
39 my $opts = $self->ssleay_get_build_opts($prefix, $exec);
41 $self->cc_inc_paths( @{ $opts->{inc_paths} } );
42 $self->cc_lib_paths( @{ $opts->{lib_paths} } );
43 $self->cc_lib_links( @{ $opts->{lib_links} } );
44 $self->cc_optimize_flags( $opts->{optimize} );
46 $self->makemaker_args( CCCDLFLAGS => $opts->{cccdlflags} );
49 "Do you want to run external tests?\n".
50 "These tests *will* *fail* if you do not have network connectivity.",
53 $self->tests('t/*/*.t t/*/*/*.t');
55 $self->tests('t/local/*.t t/handle/local/*.t');
59 sub ssleay_get_build_opts {
60 my ($self, $prefix, $exec) = @_;
63 inc_paths => ["$prefix/include", "$prefix/inc32", '/usr/kerberos/include'],
64 lib_paths => [$prefix, "$prefix/lib", "$prefix/out32dll"],
69 my $rsaref = $self->ssleay_is_rsaref;
72 *** Be sure to use the same compiler and options to compile your OpenSSL, perl,
73 and Net::SSLeay. Mixing and matching compilers is not supported.
76 if ($^O eq 'MSWin32') {
77 print "*** RSAREF build on Windows not supported out of box" if $rsaref;
78 if ($win_link_statically)
81 push @{ $opts->{lib_paths} }, "$prefix/lib/VC/static";
85 push @{ $opts->{lib_paths} }, "$prefix/lib/VC";
87 # Library names depend on the compiler. We expect either
88 # libeay32MD and ssleay32MD or
89 # libeay32 and ssleay32.
90 # This construction will not complain as long as it find at least one
91 # libssl32.a is made by openssl onWin21 with the ms/minw32.bat builder
92 push @{ $opts->{lib_links} }, qw( libeay32MD ssleay32MD libeay32 ssleay32 libssl32);
94 $opts->{optimize} = '-O2 -g';
95 push @{ $opts->{lib_links} },
97 ? qw( ssl crypto RSAglue rsaref z )
101 if (($Config{cc} =~ /aCC/i) && $^O eq 'hpux') {
102 print "*** Enabling HPUX aCC options (+e)\n";
103 $opts->{optimize} = '+e '. $opts->{optimize};
106 if ( (($Config{ccname} || $Config{cc}) eq 'gcc') && ($Config{cccdlflags} =~ /-fpic/) ) {
107 print "*** Enabling gcc -fPIC optimization\n";
108 $opts->{cccdlflags} .= '-fPIC';
115 sub ssleay_is_rsaref {
118 return $ENV{OPENSSL_RSAREF};
121 sub find_openssl_prefix {
122 my ($self, $dir) = @_;
124 if (defined $ENV{OPENSSL_PREFIX}) {
125 return $ENV{OPENSSL_PREFIX};
129 '/usr/bin/openssl' => '/usr',
130 '/usr/sbin/openssl' => '/usr',
131 '/opt/ssl/bin/openssl' => '/opt/ssl',
132 '/opt/ssl/sbin/openssl' => '/opt/ssl',
133 '/usr/local/ssl/bin/openssl' => '/usr/local/ssl',
134 '/usr/local/openssl/bin/openssl' => '/usr/local/openssl',
135 '/apps/openssl/std/bin/openssl' => '/apps/openssl/std',
136 '/usr/sfw/bin/openssl' => '/usr/sfw', # Open Solaris
137 'C:\OpenSSL\bin\openssl.exe' => 'C:\OpenSSL',
140 while (my ($k, $v) = each %guesses) {
149 sub find_openssl_exec {
150 my ($self, $prefix) = @_;
153 for my $subdir (qw( bin sbin out32dll )) {
154 my $path = File::Spec->catfile($prefix, $subdir, "openssl$Config{_exe}");
161 sub check_openssl_version {
162 my ($self, $prefix, $exec) = @_;
163 my ($major, $minor, $letter);
167 open($pipe, "$exec version |")
168 or die "Could not execute $exec";
169 my $output = <$pipe>;
173 unless ( ($major, $minor, $letter) = $output =~ /^OpenSSL\s+(\d+\.\d+)\.(\d+)([a-z]?)/ ) {
175 *** OpenSSL version test failed
176 (`$output' has been returned)
177 Either you have bogus OpenSSL or a new version has changed the version
178 number format. Please inform the authors!
183 print "*** Found OpenSSL-${major}.${minor}${letter} installed in $prefix\n";
185 if ($major < 0.9 || ($major == 0.9 && $minor < 3)) {
188 Please upgrade OpenSSL to the latest version (http://www.openssl.org/)
192 if ($major > 0.9 || ($major == 0.9 && $minor > 8)) {
194 *** That's newer than what this module was tested with
195 You should consider checking if there is a newer release of this module
196 available. Everything will probably work OK, though.
202 my ($self, $text) = @_;
204 my $sep = File::Spec->catdir('');
205 $text =~ s{\b/}{$sep}g;