621f90493ea59fa26303f3a152b1b0701560a720
[openssl.git] / util / fipsdist.pl
1
2 # FIPS distribution filter. 
3 # Takes tarball listing and removes unnecessary files and directories.
4 #
5
6
7 my $objs = "";
8 foreach (split / /, "FIPS_EX_OBJ AES_ENC BN_ASM DES_ENC SHA1_ASM_OBJ MODES_ASM_OBJ")
9         {
10         $objs .= " $ENV{$_}";
11         }
12
13
14 my @objlist = split / /, $objs;
15
16 foreach (@objlist) { $tarobjs{"$1.c"} = 1 if /([^\/]+).o$/};
17
18 $tarobjs{"ncbc_enc.c"} = 1;
19
20 foreach (split / /, $ENV{LINKDIRS} ) { $cdirs{$_} = 1 };
21
22 $cdirs{perlasm} = 1;
23
24 my %keep = 
25         (
26         "Makefile.fips" => 1,
27         "Makefile.shared" => 1,
28         "README.FIPS" => 1,
29         "e_os.h" => 1,
30         "e_os2.h" => 1,
31         "Configure" => 1,
32         "config" => 1,
33         );
34
35 while (<STDIN>)
36         {
37         chomp;
38         # Keep top level files in list
39         if (!/\// && -f $_)
40                 {
41                 next unless exists $keep{$_};
42                 }
43         else
44                 {
45                 next unless (/^(fips\/|crypto|util|test|include|ms)/);
46                 }
47         if (/^crypto\/([^\/]+)/)
48                 {
49                 # Skip unused directories under crypto/
50                 next if -d "crypto/$1" && !exists $cdirs{$1};
51                 # Keep assembly language dir, Makefile or certain extensions
52                 if (!/\/asm\// && !/\/Makefile$/ && !/\.(in|pl|h)$/)
53                         {
54                         # If C source file must be on list.
55                         next if !/(\w+\.c)$/ || !exists $tarobjs{$1};
56                         }
57                 }
58         if (/^test\//)
59                 {
60                 next unless /Makefile/ || /dummytest.c/;
61                 }
62         print "$_\n";
63         }
64 exit 1;