Don't include GF2m source files is NOEC2M set.
[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 $tarobjs{"mem_clr.c"} = 1;
20 $tarobjs{"ppccap.c"} = 1;
21
22 foreach (split / /, $ENV{LINKDIRS} ) { $cdirs{$_} = 1 };
23
24 $cdirs{perlasm} = 1;
25
26 if (exists $ENV{NOEC2M})
27         {
28         delete $tarobjs{"bn_gf2m.c"};
29         delete $tarobjs{"ec2_mult.c"};
30         delete $tarobjs{"ec2_smpl.c"};
31         delete $tarobjs{"armv4-gf2m.pl"};
32         delete $tarobjs{"x86-gf2m.pl"};
33         }
34
35 my %keep = 
36         (
37         "Makefile.fips" => 1,
38         "Makefile.shared" => 1,
39         "README.FIPS" => 1,
40         "e_os.h" => 1,
41         "e_os2.h" => 1,
42         "Configure" => 1,
43         "config" => 1,
44         );
45
46 while (<STDIN>)
47         {
48         chomp;
49         # Keep top level files in list
50         if (!/\// && -f $_)
51                 {
52                 next unless exists $keep{$_};
53                 }
54         else
55                 {
56                 next unless (/^(fips\/|crypto|util|test|include|ms)/);
57                 }
58         if (/^crypto\/([^\/]+)/)
59                 {
60                 # Skip unused directories under crypto/
61                 next if -d "crypto/$1" && !exists $cdirs{$1};
62                 # Keep assembly language dir, Makefile or certain extensions
63                 if (!/\/asm\// && !/\/Makefile$/ && !/\.(in|pl|h|S)$/)
64                         {
65                         # If C source file must be on list.
66                         next if !/(\w+\.c)$/ || !exists $tarobjs{$1};
67                         }
68                 }
69         if (/^test\//)
70                 {
71                 next unless /Makefile/ || /dummytest.c/;
72                 }
73         print "$_\n";
74         }
75 exit 1;