Various cleanups and fixed by Marc and Ralf to start the OpenTLS project
[openssl.git] / apps / g_ssleay.pl
1 #!/usr/local/bin/perl
2
3 $mkprog='mklinks';
4 $rmprog='rmlinks';
5
6 print "#ifndef NOPROTO\n";
7
8 grep(s/^asn1pars$/asn1parse/,@ARGV);
9
10 foreach (@ARGV)
11         { printf "extern int %s_main(int argc,char *argv[]);\n",$_; }
12 print "#else\n";
13 foreach (@ARGV)
14         { printf "extern int %s_main();\n",$_; }
15 print "#endif\n";
16
17
18 print <<'EOF';
19
20 #ifdef SSLEAY_SRC
21
22 #define FUNC_TYPE_GENERAL       1
23 #define FUNC_TYPE_MD            2
24 #define FUNC_TYPE_CIPHER        3
25
26 typedef struct {
27         int type;
28         char *name;
29         int (*func)();
30         } FUNCTION;
31
32 FUNCTION functions[] = {
33 EOF
34
35 foreach (@ARGV)
36         {
37         push(@files,$_);
38         $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
39         if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
40                 { print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))\n${str}#endif\n"; } 
41         elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) ||
42                 ($_ =~ /^req$/) || ($_ =~ /^ca$/) || ($_ =~ /^x509$/))
43                 { print "#ifndef NO_RSA\n${str}#endif\n";  }
44         elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
45                 { print "#ifndef NO_DSA\n${str}#endif\n"; }
46         elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/))
47                 { print "#ifndef NO_DH\n${str}#endif\n"; }
48         else
49                 { print $str; }
50         }
51
52 foreach ("md2","md5","sha","sha1","mdc2","rmd160")
53         {
54         push(@files,$_);
55         printf "\t{FUNC_TYPE_MD,\"%s\",dgst_main},\n",$_;
56         }
57
58 foreach (
59         "base64",
60         "des", "des3", "desx", "idea", "rc4", "rc2","bf","cast","rc5",
61         "des-ecb", "des-ede",    "des-ede3",
62         "des-cbc", "des-ede-cbc","des-ede3-cbc",
63         "des-cfb", "des-ede-cfb","des-ede3-cfb",
64         "des-ofb", "des-ede-ofb","des-ede3-ofb",
65         "idea-cbc","idea-ecb",   "idea-cfb", "idea-ofb",
66         "rc2-cbc", "rc2-ecb",    "rc2-cfb",  "rc2-ofb",
67         "bf-cbc",  "bf-ecb",     "bf-cfb",   "bf-ofb",
68         "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
69         "cast-cbc", "rc5-cbc",   "rc5-ecb",  "rc5-cfb",  "rc5-ofb")
70         {
71         push(@files,$_);
72
73         $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
74         if    ($_ =~ /des/)  { $t="#ifndef NO_DES\n${t}#endif\n"; }
75         elsif ($_ =~ /idea/) { $t="#ifndef NO_IDEA\n${t}#endif\n"; }
76         elsif ($_ =~ /rc4/)  { $t="#ifndef NO_RC4\n${t}#endif\n"; }
77         elsif ($_ =~ /rc2/)  { $t="#ifndef NO_RC2\n${t}#endif\n"; }
78         elsif ($_ =~ /bf/)   { $t="#ifndef NO_BLOWFISH\n${t}#endif\n"; }
79         elsif ($_ =~ /cast/) { $t="#ifndef NO_CAST\n${t}#endif\n"; }
80         elsif ($_ =~ /rc5/)  { $t="#ifndef NO_RC5\n${t}#endif\n"; }
81         print $t;
82         }
83
84 print "\t{0,NULL,NULL}\n\t};\n";
85 print "#endif\n\n";
86
87 open(OUT,">$mkprog") || die "unable to open '$prog':$!\n";
88 print OUT "#!/bin/sh\nfor i in ";
89 foreach (@files)
90         { print OUT $_." "; }
91 print OUT <<'EOF';
92
93 do
94 echo making symlink for $i
95 /bin/rm -f $i
96 ln -s ssleay $i
97 done
98 EOF
99 close(OUT);
100 chmod(0755,$mkprog);
101
102 open(OUT,">$rmprog") || die "unable to open '$prog':$!\n";
103 print OUT "#!/bin/sh\nfor i in ";
104 foreach (@files)
105         { print OUT $_." "; }
106 print OUT <<'EOF';
107
108 do
109 echo removing $i
110 /bin/rm -f $i
111 done
112 EOF
113 close(OUT);
114 chmod(0755,$rmprog);