]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/OpensslLib/process_files.pl
CryptoPkg: Convert files to CRLF line ending
[mirror_edk2.git] / CryptoPkg / Library / OpensslLib / process_files.pl
index 210811b9ed3659d966e5eb1a6de737aedafd670f..4a60073485b24af4b51ba0d2f2dd447f428c9db5 100644 (file)
-#!/usr/bin/perl -w
-#
-# This script runs the OpenSSL Configure script, then processes the
-# resulting file list into our local OpensslLib[Crypto].inf and also
-# takes a copy of opensslconf.h.
-#
-# This only needs to be done once by a developer when updating to a
-# new version of OpenSSL (or changing options, etc.). Normal users
-# do not need to do this, since the results are stored in the EDK2
-# git repository for them.
-#
-use strict;
-use Cwd;
-use File::Copy;
-
-#
-# Find the openssl directory name for use lib. We have to do this
-# inside of BEGIN. The variables we create here, however, don't seem
-# to be available to the main script, so we have to repeat the
-# exercise.
-#
-my $inf_file;
-my $OPENSSL_PATH;
-my @inf;
-
-BEGIN {
-    $inf_file = "OpensslLib.inf";
-
-    # Read the contents of the inf file
-    open( FD, "<" . $inf_file ) ||
-        die "Cannot open \"" . $inf_file . "\"!";
-    @inf = (<FD>);
-    close(FD) ||
-        die "Cannot close \"" . $inf_file . "\"!";
-
-    foreach (@inf) {
-        if (/DEFINE\s+OPENSSL_PATH\s*=\s*([a-z]+)/) {
-
-            # We need to run Configure before we can include its result...
-            $OPENSSL_PATH = $1;
-
-            my $basedir = getcwd();
-
-            chdir($OPENSSL_PATH) ||
-                die "Cannot change to OpenSSL directory \"" . $OPENSSL_PATH . "\"";
-
-            # Configure UEFI
-            system(
-                "./Configure",
-                "UEFI",
-                "no-afalgeng",
-                "no-asm",
-                "no-async",
-                "no-autoalginit",
-                "no-autoerrinit",
-                "no-bf",
-                "no-blake2",
-                "no-camellia",
-                "no-capieng",
-                "no-cast",
-                "no-chacha",
-                "no-cms",
-                "no-ct",
-                "no-deprecated",
-                "no-dgram",
-                "no-dsa",
-                "no-dynamic-engine",
-                "no-ec",
-                "no-ec2m",
-                "no-engine",
-                "no-err",
-                "no-filenames",
-                "no-gost",
-                "no-hw",
-                "no-idea",
-                "no-mdc2",
-                "no-pic",
-                "no-ocb",
-                "no-poly1305",
-                "no-posix-io",
-                "no-rc2",
-                "no-rfc3779",
-                "no-rmd160",
-                "no-scrypt",
-                "no-seed",
-                "no-sock",
-                "no-srp",
-                "no-ssl",
-                "no-stdio",
-                "no-threads",
-                "no-ts",
-                "no-ui",
-                "no-whirlpool"
-                ) == 0 ||
-                    die "OpenSSL Configure failed!\n";
-
-            # Generate opensslconf.h per config data
-            system(
-                "perl -I. -Mconfigdata util/dofile.pl " .
-                "include/openssl/opensslconf.h.in " .
-                "> include/openssl/opensslconf.h"
-                ) == 0 ||
-                    die "Failed to generate opensslconf.h!\n";
-
-            chdir($basedir) ||
-                die "Cannot change to base directory \"" . $basedir . "\"";
-
-            push @INC, $1;
-            last;
-        }
-    }
-}
-
-#
-# Retrieve file lists from OpenSSL configdata
-#
-use configdata qw/%unified_info/;
-
-my @cryptofilelist = ();
-my @sslfilelist = ();
-foreach my $product ((@{$unified_info{libraries}},
-                      @{$unified_info{engines}})) {
-    foreach my $o (@{$unified_info{sources}->{$product}}) {
-        foreach my $s (@{$unified_info{sources}->{$o}}) {
-            next if ($unified_info{generate}->{$s});
-            next if $s =~ "crypto/bio/b_print.c";
-            if ($product =~ "libssl") {
-                push @sslfilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";
-                next;
-            }
-            push @cryptofilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";
-        }
-    }
-}
-
-#
-# Update OpensslLib.inf with autogenerated file list
-#
-my @new_inf = ();
-my $subbing = 0;
-print "\n--> Updating OpensslLib.inf ... ";
-foreach (@inf) {
-    if ( $_ =~ "# Autogenerated files list starts here" ) {
-        push @new_inf, $_, @cryptofilelist, @sslfilelist;
-        $subbing = 1;
-        next;
-    }
-    if ( $_ =~ "# Autogenerated files list ends here" ) {
-        push @new_inf, $_;
-        $subbing = 0;
-        next;
-    }
-
-    push @new_inf, $_
-        unless ($subbing);
-}
-
-my $new_inf_file = $inf_file . ".new";
-open( FD, ">" . $new_inf_file ) ||
-    die $new_inf_file;
-print( FD @new_inf ) ||
-    die $new_inf_file;
-close(FD) ||
-    die $new_inf_file;
-rename( $new_inf_file, $inf_file ) ||
-    die "rename $inf_file";
-print "Done!";
-
-#
-# Update OpensslLibCrypto.inf with auto-generated file list (no libssl)
-#
-$inf_file = "OpensslLibCrypto.inf";
-
-# Read the contents of the inf file
-@inf = ();
-@new_inf = ();
-open( FD, "<" . $inf_file ) ||
-    die "Cannot open \"" . $inf_file . "\"!";
-@inf = (<FD>);
-close(FD) ||
-    die "Cannot close \"" . $inf_file . "\"!";
-
-$subbing = 0;
-print "\n--> Updating OpensslLibCrypto.inf ... ";
-foreach (@inf) {
-    if ( $_ =~ "# Autogenerated files list starts here" ) {
-        push @new_inf, $_, @cryptofilelist;
-        $subbing = 1;
-        next;
-    }
-    if ( $_ =~ "# Autogenerated files list ends here" ) {
-        push @new_inf, $_;
-        $subbing = 0;
-        next;
-    }
-
-    push @new_inf, $_
-        unless ($subbing);
-}
-
-$new_inf_file = $inf_file . ".new";
-open( FD, ">" . $new_inf_file ) ||
-    die $new_inf_file;
-print( FD @new_inf ) ||
-    die $new_inf_file;
-close(FD) ||
-    die $new_inf_file;
-rename( $new_inf_file, $inf_file ) ||
-    die "rename $inf_file";
-print "Done!";
-
-#
-# Copy opensslconf.h generated from OpenSSL Configuration
-#
-print "\n--> Duplicating opensslconf.h into Include/openssl ... ";
-copy($OPENSSL_PATH . "/include/openssl/opensslconf.h",
-     $OPENSSL_PATH . "/../../../Include/openssl/") ||
-   die "Cannot copy opensslconf.h!";
-print "Done!\n";
-
-print "\nProcessing Files Done!\n";
-
-exit(0);
+#!/usr/bin/perl -w\r
+#\r
+# This script runs the OpenSSL Configure script, then processes the\r
+# resulting file list into our local OpensslLib[Crypto].inf and also\r
+# takes a copy of opensslconf.h.\r
+#\r
+# This only needs to be done once by a developer when updating to a\r
+# new version of OpenSSL (or changing options, etc.). Normal users\r
+# do not need to do this, since the results are stored in the EDK2\r
+# git repository for them.\r
+#\r
+use strict;\r
+use Cwd;\r
+use File::Copy;\r
+\r
+#\r
+# Find the openssl directory name for use lib. We have to do this\r
+# inside of BEGIN. The variables we create here, however, don't seem\r
+# to be available to the main script, so we have to repeat the\r
+# exercise.\r
+#\r
+my $inf_file;\r
+my $OPENSSL_PATH;\r
+my @inf;\r
+\r
+BEGIN {\r
+    $inf_file = "OpensslLib.inf";\r
+\r
+    # Read the contents of the inf file\r
+    open( FD, "<" . $inf_file ) ||\r
+        die "Cannot open \"" . $inf_file . "\"!";\r
+    @inf = (<FD>);\r
+    close(FD) ||\r
+        die "Cannot close \"" . $inf_file . "\"!";\r
+\r
+    foreach (@inf) {\r
+        if (/DEFINE\s+OPENSSL_PATH\s*=\s*([a-z]+)/) {\r
+\r
+            # We need to run Configure before we can include its result...\r
+            $OPENSSL_PATH = $1;\r
+\r
+            my $basedir = getcwd();\r
+\r
+            chdir($OPENSSL_PATH) ||\r
+                die "Cannot change to OpenSSL directory \"" . $OPENSSL_PATH . "\"";\r
+\r
+            # Configure UEFI\r
+            system(\r
+                "./Configure",\r
+                "UEFI",\r
+                "no-afalgeng",\r
+                "no-asm",\r
+                "no-async",\r
+                "no-autoalginit",\r
+                "no-autoerrinit",\r
+                "no-bf",\r
+                "no-blake2",\r
+                "no-camellia",\r
+                "no-capieng",\r
+                "no-cast",\r
+                "no-chacha",\r
+                "no-cms",\r
+                "no-ct",\r
+                "no-deprecated",\r
+                "no-dgram",\r
+                "no-dsa",\r
+                "no-dynamic-engine",\r
+                "no-ec",\r
+                "no-ec2m",\r
+                "no-engine",\r
+                "no-err",\r
+                "no-filenames",\r
+                "no-gost",\r
+                "no-hw",\r
+                "no-idea",\r
+                "no-mdc2",\r
+                "no-pic",\r
+                "no-ocb",\r
+                "no-poly1305",\r
+                "no-posix-io",\r
+                "no-rc2",\r
+                "no-rfc3779",\r
+                "no-rmd160",\r
+                "no-scrypt",\r
+                "no-seed",\r
+                "no-sock",\r
+                "no-srp",\r
+                "no-ssl",\r
+                "no-stdio",\r
+                "no-threads",\r
+                "no-ts",\r
+                "no-ui",\r
+                "no-whirlpool"\r
+                ) == 0 ||\r
+                    die "OpenSSL Configure failed!\n";\r
+\r
+            # Generate opensslconf.h per config data\r
+            system(\r
+                "perl -I. -Mconfigdata util/dofile.pl " .\r
+                "include/openssl/opensslconf.h.in " .\r
+                "> include/openssl/opensslconf.h"\r
+                ) == 0 ||\r
+                    die "Failed to generate opensslconf.h!\n";\r
+\r
+            chdir($basedir) ||\r
+                die "Cannot change to base directory \"" . $basedir . "\"";\r
+\r
+            push @INC, $1;\r
+            last;\r
+        }\r
+    }\r
+}\r
+\r
+#\r
+# Retrieve file lists from OpenSSL configdata\r
+#\r
+use configdata qw/%unified_info/;\r
+\r
+my @cryptofilelist = ();\r
+my @sslfilelist = ();\r
+foreach my $product ((@{$unified_info{libraries}},\r
+                      @{$unified_info{engines}})) {\r
+    foreach my $o (@{$unified_info{sources}->{$product}}) {\r
+        foreach my $s (@{$unified_info{sources}->{$o}}) {\r
+            next if ($unified_info{generate}->{$s});\r
+            next if $s =~ "crypto/bio/b_print.c";\r
+            if ($product =~ "libssl") {\r
+                push @sslfilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";\r
+                next;\r
+            }\r
+            push @cryptofilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";\r
+        }\r
+    }\r
+}\r
+\r
+#\r
+# Update OpensslLib.inf with autogenerated file list\r
+#\r
+my @new_inf = ();\r
+my $subbing = 0;\r
+print "\n--> Updating OpensslLib.inf ... ";\r
+foreach (@inf) {\r
+    if ( $_ =~ "# Autogenerated files list starts here" ) {\r
+        push @new_inf, $_, @cryptofilelist, @sslfilelist;\r
+        $subbing = 1;\r
+        next;\r
+    }\r
+    if ( $_ =~ "# Autogenerated files list ends here" ) {\r
+        push @new_inf, $_;\r
+        $subbing = 0;\r
+        next;\r
+    }\r
+\r
+    push @new_inf, $_\r
+        unless ($subbing);\r
+}\r
+\r
+my $new_inf_file = $inf_file . ".new";\r
+open( FD, ">" . $new_inf_file ) ||\r
+    die $new_inf_file;\r
+print( FD @new_inf ) ||\r
+    die $new_inf_file;\r
+close(FD) ||\r
+    die $new_inf_file;\r
+rename( $new_inf_file, $inf_file ) ||\r
+    die "rename $inf_file";\r
+print "Done!";\r
+\r
+#\r
+# Update OpensslLibCrypto.inf with auto-generated file list (no libssl)\r
+#\r
+$inf_file = "OpensslLibCrypto.inf";\r
+\r
+# Read the contents of the inf file\r
+@inf = ();\r
+@new_inf = ();\r
+open( FD, "<" . $inf_file ) ||\r
+    die "Cannot open \"" . $inf_file . "\"!";\r
+@inf = (<FD>);\r
+close(FD) ||\r
+    die "Cannot close \"" . $inf_file . "\"!";\r
+\r
+$subbing = 0;\r
+print "\n--> Updating OpensslLibCrypto.inf ... ";\r
+foreach (@inf) {\r
+    if ( $_ =~ "# Autogenerated files list starts here" ) {\r
+        push @new_inf, $_, @cryptofilelist;\r
+        $subbing = 1;\r
+        next;\r
+    }\r
+    if ( $_ =~ "# Autogenerated files list ends here" ) {\r
+        push @new_inf, $_;\r
+        $subbing = 0;\r
+        next;\r
+    }\r
+\r
+    push @new_inf, $_\r
+        unless ($subbing);\r
+}\r
+\r
+$new_inf_file = $inf_file . ".new";\r
+open( FD, ">" . $new_inf_file ) ||\r
+    die $new_inf_file;\r
+print( FD @new_inf ) ||\r
+    die $new_inf_file;\r
+close(FD) ||\r
+    die $new_inf_file;\r
+rename( $new_inf_file, $inf_file ) ||\r
+    die "rename $inf_file";\r
+print "Done!";\r
+\r
+#\r
+# Copy opensslconf.h generated from OpenSSL Configuration\r
+#\r
+print "\n--> Duplicating opensslconf.h into Include/openssl ... ";\r
+copy($OPENSSL_PATH . "/include/openssl/opensslconf.h",\r
+     $OPENSSL_PATH . "/../../../Include/openssl/") ||\r
+   die "Cannot copy opensslconf.h!";\r
+print "Done!\n";\r
+\r
+print "\nProcessing Files Done!\n";\r
+\r
+exit(0);\r
+\r