]>
git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/process_files.pl
4fe54cd808a5e1987d11ee1743840c8f6b41c312
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 # OpenSSL1_1_1b doesn't support default rand-seed-os for UEFI
96 # UEFI only support --with-rand-seed=none
97 "--with-rand-seed=none"
99 die "OpenSSL Configure failed!\n";
101 # Generate opensslconf.h per config data
103 "perl -I. -Mconfigdata util/dofile.pl " .
104 "include/openssl/opensslconf.h.in " .
105 "> include/openssl/opensslconf.h"
107 die "Failed to generate opensslconf.h!\n";
110 die "Cannot change to base directory \"" . $basedir . "\"";
119 # Retrieve file lists from OpenSSL configdata
121 use configdata qw
/%unified_info/;
123 my @cryptofilelist = ();
124 my @sslfilelist = ();
125 foreach my $product ((@{$unified_info{libraries
}},
126 @{$unified_info{engines
}})) {
127 foreach my $o (@{$unified_info{sources
}->{$product}}) {
128 foreach my $s (@{$unified_info{sources
}->{$o}}) {
129 next if ($unified_info{generate
}->{$s});
130 next if $s =~ "crypto/bio/b_print.c";
132 # No need to add unused files in UEFI.
133 # So it can reduce porting time, compile time, library size.
134 next if $s =~ "crypto/rand/randfile.c";
135 next if $s =~ "crypto/store/";
136 next if $s =~ "crypto/err/err_all.c";
138 if ($product =~ "libssl") {
139 push @sslfilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
142 push @cryptofilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
149 # Update the perl script to generate the missing header files
152 for (keys %{$unified_info{dirinfo
}}){
161 @files = glob($_."/*.h");
162 push @headers, @files;
168 push @sslfilelist, ' $(OPENSSL_PATH)/' . $_ . "\r\n";
171 push @cryptofilelist, ' $(OPENSSL_PATH)/' . $_ . "\r\n";
176 # Update OpensslLib.inf with autogenerated file list
180 print "\n--> Updating OpensslLib.inf ... ";
182 if ( $_ =~ "# Autogenerated files list starts here" ) {
183 push @new_inf, $_, @cryptofilelist, @sslfilelist;
187 if ( $_ =~ "# Autogenerated files list ends here" ) {
197 my $new_inf_file = $inf_file . ".new";
198 open( FD
, ">" . $new_inf_file ) ||
200 print( FD
@new_inf ) ||
204 rename( $new_inf_file, $inf_file ) ||
205 die "rename $inf_file";
209 # Update OpensslLibCrypto.inf with auto-generated file list (no libssl)
211 $inf_file = "OpensslLibCrypto.inf";
213 # Read the contents of the inf file
216 open( FD
, "<" . $inf_file ) ||
217 die "Cannot open \"" . $inf_file . "\"!";
220 die "Cannot close \"" . $inf_file . "\"!";
223 print "\n--> Updating OpensslLibCrypto.inf ... ";
225 if ( $_ =~ "# Autogenerated files list starts here" ) {
226 push @new_inf, $_, @cryptofilelist;
230 if ( $_ =~ "# Autogenerated files list ends here" ) {
240 $new_inf_file = $inf_file . ".new";
241 open( FD
, ">" . $new_inf_file ) ||
243 print( FD
@new_inf ) ||
247 rename( $new_inf_file, $inf_file ) ||
248 die "rename $inf_file";
252 # Copy opensslconf.h generated from OpenSSL Configuration
254 print "\n--> Duplicating opensslconf.h into Include/openssl ... ";
255 copy
($OPENSSL_PATH . "/include/openssl/opensslconf.h",
256 $OPENSSL_PATH . "/../../Include/openssl/") ||
257 die "Cannot copy opensslconf.h!";
260 print "\nProcessing Files Done!\n";