RT4033: Use OPENSSL_SYS_UNIX not "unix"
[openssl.git] / apps / progs.pl
1 #!/usr/local/bin/perl
2 # Generate progs.h file from list of "programs" passed on the command line.
3
4 print <<'EOF';
5 /*
6  * Automatically generated by progs.pl for openssl.c
7  * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.
8  * See the openssl.c for copyright details.
9  */
10
11 typedef enum FUNC_TYPE {
12     FT_none, FT_general, FT_md, FT_cipher, FT_pkey,
13     FT_md_alg, FT_cipher_alg
14 } FUNC_TYPE;
15
16 typedef struct function_st {
17     FUNC_TYPE type;
18     const char *name;
19     int (*func)(int argc,char *argv[]);
20     const OPTIONS *help;
21 } FUNCTION;
22
23 EOF
24
25 grep(s/\.o//, @ARGV);
26 grep(s/^asn1pars$/asn1parse/, @ARGV);
27 grep(s/^crl2p7$/crl2pkcs7/, @ARGV);
28 push @ARGV, 'list';
29 push @ARGV, 'help';
30 push @ARGV, 'exit';
31
32 foreach (@ARGV) {
33         printf "extern int %s_main(int argc, char *argv[]);\n", $_;
34 }
35
36 print "\n";
37
38 foreach (@ARGV) {
39         printf "extern OPTIONS %s_options[];\n", $_;
40 }
41 print "\n#ifdef INCLUDE_FUNCTION_TABLE\n";
42 print "static FUNCTION functions[] = {\n";
43 foreach (@ARGV) {
44         $str="    { FT_general, \"$_\", ${_}_main, ${_}_options },\n";
45         if (/^s_/ || /^ciphers$/) {
46                 print "#if !defined(OPENSSL_NO_SOCK)\n${str}#endif\n";
47         } elsif (/^engine$/) {
48                 print "#ifndef OPENSSL_NO_ENGINE\n${str}#endif\n";
49         } elsif (/^rsa$/ || /^genrsa$/ || /^rsautl$/) {
50                 print "#ifndef OPENSSL_NO_RSA\n${str}#endif\n";
51         } elsif (/^dsa$/ || /^gendsa$/ || /^dsaparam$/) {
52                 print "#ifndef OPENSSL_NO_DSA\n${str}#endif\n";
53         } elsif (/^ec$/ || /^ecparam$/) {
54                 print "#ifndef OPENSSL_NO_EC\n${str}#endif\n";
55         } elsif (/^dh$/ || /^gendh$/ || /^dhparam$/) {
56                 print "#ifndef OPENSSL_NO_DH\n${str}#endif\n";
57         } elsif (/^pkcs12$/) {
58                 print "#if !defined(OPENSSL_NO_DES)\n${str}#endif\n";
59         } elsif (/^cms$/) {
60                 print "#ifndef OPENSSL_NO_CMS\n${str}#endif\n";
61         } elsif (/^ocsp$/) {
62                 print "#ifndef OPENSSL_NO_OCSP\n${str}#endif\n";
63         } elsif (/^srp$/) {
64                 print "#ifndef OPENSSL_NO_SRP\n${str}#endif\n";
65         } else {
66                 print $str;
67         }
68 }
69
70 foreach (
71         "md2", "md4", "md5",
72         "md_ghost94",
73         "sha", "sha1", "sha224", "sha256", "sha384", "sha512",
74         "mdc2", "rmd160"
75 ) {
76         printf "#ifndef OPENSSL_NO_".uc($_)."\n" if ! /sha/;
77         printf "    { FT_md, \"".$_."\", dgst_main},\n";
78         printf "#endif\n" if ! /sha/;
79 }
80
81 foreach (
82         "aes-128-cbc", "aes-128-ecb",
83         "aes-192-cbc", "aes-192-ecb",
84         "aes-256-cbc", "aes-256-ecb",
85         "camellia-128-cbc", "camellia-128-ecb",
86         "camellia-192-cbc", "camellia-192-ecb",
87         "camellia-256-cbc", "camellia-256-ecb",
88         "base64", "zlib",
89         "des", "des3", "desx", "idea", "seed", "rc4", "rc4-40",
90         "rc2", "bf", "cast", "rc5",
91         "des-ecb", "des-ede",    "des-ede3",
92         "des-cbc", "des-ede-cbc","des-ede3-cbc",
93         "des-cfb", "des-ede-cfb","des-ede3-cfb",
94         "des-ofb", "des-ede-ofb","des-ede3-ofb",
95         "idea-cbc","idea-ecb",    "idea-cfb", "idea-ofb",
96         "seed-cbc","seed-ecb",    "seed-cfb", "seed-ofb",
97         "rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
98         "bf-cbc",  "bf-ecb",     "bf-cfb",   "bf-ofb",
99         "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
100         "cast-cbc", "rc5-cbc",   "rc5-ecb",  "rc5-cfb",  "rc5-ofb"
101 ) {
102         $str="    { FT_cipher, \"$_\", enc_main, enc_options },\n";
103         if (/des/) {
104                 printf "#ifndef OPENSSL_NO_DES\n${str}#endif\n";
105         } elsif (/aes/) {
106                 printf "#ifndef OPENSSL_NO_AES\n${str}#endif\n";
107         } elsif (/camellia/) {
108                 printf "#ifndef OPENSSL_NO_CAMELLIA\n${str}#endif\n";
109         } elsif (/idea/) {
110                 printf "#ifndef OPENSSL_NO_IDEA\n${str}#endif\n";
111         } elsif (/seed/) {
112                 printf "#ifndef OPENSSL_NO_SEED\n${str}#endif\n";
113         } elsif (/rc4/) {
114                 printf "#ifndef OPENSSL_NO_RC4\n${str}#endif\n";
115         } elsif (/rc2/) {
116                 printf "#ifndef OPENSSL_NO_RC2\n${str}#endif\n";
117         } elsif (/bf/) {
118                 printf "#ifndef OPENSSL_NO_BF\n${str}#endif\n";
119         } elsif (/cast/) {
120                 printf "#ifndef OPENSSL_NO_CAST\n${str}#endif\n";
121         } elsif (/rc5/) {
122                 printf "#ifndef OPENSSL_NO_RC5\n${str}#endif\n";
123         } elsif (/zlib/) {
124                 printf "#ifdef ZLIB\n${str}#endif\n";
125         } else {
126                 print $str;
127         }
128 }
129
130 print "    { 0, NULL, NULL}\n};\n";
131 printf "#endif\n";