]>
git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/process_files.pl
3 # This script runs the OpenSSL Configure script, then processes the
4 # resulting file list into our local OpensslLib[Crypto].inf and also
5 # takes a copy of opensslconf.h.
7 # This only needs to be done once by a developer when updating to a
8 # new version of OpenSSL (or changing options, etc.). Normal users
9 # do not need to do this, since the results are stored in the EDK2
10 # git repository for them.
17 # Find the openssl directory name for use lib. We have to do this
18 # inside of BEGIN. The variables we create here, however, don't seem
19 # to be available to the main script, so we have to repeat the
27 $inf_file = "OpensslLib.inf";
29 # Read the contents of the inf file
30 open( FD
, "<" . $inf_file ) ||
31 die "Cannot open \"" . $inf_file . "\"!";
34 die "Cannot close \"" . $inf_file . "\"!";
37 if (/DEFINE\s+OPENSSL_PATH\s*=\s*([a-z]+)/) {
39 # We need to run Configure before we can include its result...
42 my $basedir = getcwd
();
44 chdir($OPENSSL_PATH) ||
45 die "Cannot change to OpenSSL directory \"" . $OPENSSL_PATH . "\"";
95 die "OpenSSL Configure failed!\n";
97 # Generate opensslconf.h per config data
99 "perl -I. -Mconfigdata util/dofile.pl " .
100 "include/openssl/opensslconf.h.in " .
101 "> include/openssl/opensslconf.h"
103 die "Failed to generate opensslconf.h!\n";
106 die "Cannot change to base directory \"" . $basedir . "\"";
115 # Retrieve file lists from OpenSSL configdata
117 use configdata qw
/%unified_info/;
119 my @cryptofilelist = ();
120 my @sslfilelist = ();
121 foreach my $product ((@{$unified_info{libraries
}},
122 @{$unified_info{engines
}})) {
123 foreach my $o (@{$unified_info{sources
}->{$product}}) {
124 foreach my $s (@{$unified_info{sources
}->{$o}}) {
125 next if ($unified_info{generate
}->{$s});
126 next if $s =~ "crypto/bio/b_print.c";
127 if ($product =~ "libssl") {
128 push @sslfilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
131 push @cryptofilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
137 # Update OpensslLib.inf with autogenerated file list
141 print "\n--> Updating OpensslLib.inf ... ";
143 if ( $_ =~ "# Autogenerated files list starts here" ) {
144 push @new_inf, $_, @cryptofilelist, @sslfilelist;
148 if ( $_ =~ "# Autogenerated files list ends here" ) {
158 my $new_inf_file = $inf_file . ".new";
159 open( FD
, ">" . $new_inf_file ) ||
161 print( FD
@new_inf ) ||
165 rename( $new_inf_file, $inf_file ) ||
166 die "rename $inf_file";
170 # Update OpensslLibCrypto.inf with auto-generated file list (no libssl)
172 $inf_file = "OpensslLibCrypto.inf";
174 # Read the contents of the inf file
177 open( FD
, "<" . $inf_file ) ||
178 die "Cannot open \"" . $inf_file . "\"!";
181 die "Cannot close \"" . $inf_file . "\"!";
184 print "\n--> Updating OpensslLibCrypto.inf ... ";
186 if ( $_ =~ "# Autogenerated files list starts here" ) {
187 push @new_inf, $_, @cryptofilelist;
191 if ( $_ =~ "# Autogenerated files list ends here" ) {
201 $new_inf_file = $inf_file . ".new";
202 open( FD
, ">" . $new_inf_file ) ||
204 print( FD
@new_inf ) ||
208 rename( $new_inf_file, $inf_file ) ||
209 die "rename $inf_file";
213 # Copy opensslconf.h generated from OpenSSL Configuration
215 print "\n--> Duplicating opensslconf.h into Include/openssl ... ";
216 copy
($OPENSSL_PATH . "/include/openssl/opensslconf.h",
217 $OPENSSL_PATH . "/../../Include/openssl/") ||
218 die "Cannot copy opensslconf.h!";
221 print "\nProcessing Files Done!\n";