diff options
Diffstat (limited to 'src/lib/libcrypto/util')
-rw-r--r-- | src/lib/libcrypto/util/copy.pl | 70 | ||||
-rw-r--r-- | src/lib/libcrypto/util/domd | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/util/extract-section.pl | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/util/libeay.num | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/util/mk1mf.pl | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/util/mkerr.pl | 715 | ||||
-rw-r--r-- | src/lib/libcrypto/util/mkstack.pl | 126 | ||||
-rw-r--r-- | src/lib/libcrypto/util/pl/VC-32.pl | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/util/pl/netware.pl | 526 |
9 files changed, 1455 insertions, 8 deletions
diff --git a/src/lib/libcrypto/util/copy.pl b/src/lib/libcrypto/util/copy.pl new file mode 100644 index 0000000000..eba6d5815e --- /dev/null +++ b/src/lib/libcrypto/util/copy.pl | |||
@@ -0,0 +1,70 @@ | |||
1 | #!/usr/local/bin/perl | ||
2 | |||
3 | use Fcntl; | ||
4 | |||
5 | |||
6 | # copy.pl | ||
7 | |||
8 | # Perl script 'copy' comment. On Windows the built in "copy" command also | ||
9 | # copies timestamps: this messes up Makefile dependencies. | ||
10 | |||
11 | my $stripcr = 0; | ||
12 | |||
13 | my $arg; | ||
14 | |||
15 | foreach $arg (@ARGV) { | ||
16 | if ($arg eq "-stripcr") | ||
17 | { | ||
18 | $stripcr = 1; | ||
19 | next; | ||
20 | } | ||
21 | $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... | ||
22 | foreach (glob $arg) | ||
23 | { | ||
24 | push @filelist, $_; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | $fnum = @filelist; | ||
29 | |||
30 | if ($fnum <= 1) | ||
31 | { | ||
32 | die "Need at least two filenames"; | ||
33 | } | ||
34 | |||
35 | $dest = pop @filelist; | ||
36 | |||
37 | if ($fnum > 2 && ! -d $dest) | ||
38 | { | ||
39 | die "Destination must be a directory"; | ||
40 | } | ||
41 | |||
42 | foreach (@filelist) | ||
43 | { | ||
44 | if (-d $dest) | ||
45 | { | ||
46 | $dfile = $_; | ||
47 | $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|; | ||
48 | $dfile = "$dest/$dfile"; | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | $dfile = $dest; | ||
53 | } | ||
54 | sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_"; | ||
55 | sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY) | ||
56 | || die "Can't Open $dfile"; | ||
57 | while (sysread IN, $buf, 10240) | ||
58 | { | ||
59 | if ($stripcr) | ||
60 | { | ||
61 | $buf =~ tr/\015//d; | ||
62 | } | ||
63 | syswrite(OUT, $buf, length($buf)); | ||
64 | } | ||
65 | close(IN); | ||
66 | close(OUT); | ||
67 | print "Copying: $_ to $dfile\n"; | ||
68 | } | ||
69 | |||
70 | |||
diff --git a/src/lib/libcrypto/util/domd b/src/lib/libcrypto/util/domd index 560ebeaf82..691be7a440 100644 --- a/src/lib/libcrypto/util/domd +++ b/src/lib/libcrypto/util/domd | |||
@@ -22,7 +22,7 @@ if [ "$MAKEDEPEND" = "gcc" ]; then | |||
22 | done | 22 | done |
23 | sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp | 23 | sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp |
24 | echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp | 24 | echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp |
25 | ${CC:-gcc} -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp | 25 | gcc -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp |
26 | ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new | 26 | ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new |
27 | rm -f Makefile.tmp | 27 | rm -f Makefile.tmp |
28 | else | 28 | else |
diff --git a/src/lib/libcrypto/util/extract-section.pl b/src/lib/libcrypto/util/extract-section.pl new file mode 100644 index 0000000000..7a0ba4f69a --- /dev/null +++ b/src/lib/libcrypto/util/extract-section.pl | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | while(<STDIN>) { | ||
4 | if (/=for\s+comment\s+openssl_manual_section:(\S+)/) | ||
5 | { | ||
6 | print "$1\n"; | ||
7 | exit 0; | ||
8 | } | ||
9 | } | ||
10 | |||
11 | print "$ARGV[0]\n"; | ||
12 | |||
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num index 74eb337227..0eb54ddc89 100644 --- a/src/lib/libcrypto/util/libeay.num +++ b/src/lib/libcrypto/util/libeay.num | |||
@@ -3667,8 +3667,7 @@ CRYPTO_set_mem_info_functions 4053 EXIST::FUNCTION: | |||
3667 | RSA_X931_generate_key_ex 4054 EXIST::FUNCTION:RSA | 3667 | RSA_X931_generate_key_ex 4054 EXIST::FUNCTION:RSA |
3668 | int_ERR_set_state_func 4055 EXIST:OPENSSL_FIPS:FUNCTION: | 3668 | int_ERR_set_state_func 4055 EXIST:OPENSSL_FIPS:FUNCTION: |
3669 | int_EVP_MD_set_engine_callbacks 4056 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE | 3669 | int_EVP_MD_set_engine_callbacks 4056 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE |
3670 | int_CRYPTO_set_do_dynlock_callback 4057 EXIST:!VMS:FUNCTION: | 3670 | int_CRYPTO_set_do_dynlock_callback 4057 EXIST::FUNCTION: |
3671 | int_CRYPTO_set_do_dynlock_cb 4057 EXIST:VMS:FUNCTION: | ||
3672 | FIPS_rng_stick 4058 EXIST:OPENSSL_FIPS:FUNCTION: | 3671 | FIPS_rng_stick 4058 EXIST:OPENSSL_FIPS:FUNCTION: |
3673 | EVP_CIPHER_CTX_set_flags 4059 EXIST::FUNCTION: | 3672 | EVP_CIPHER_CTX_set_flags 4059 EXIST::FUNCTION: |
3674 | BN_X931_generate_prime_ex 4060 EXIST::FUNCTION: | 3673 | BN_X931_generate_prime_ex 4060 EXIST::FUNCTION: |
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl index f2b92b2b25..4c16f1dc9e 100644 --- a/src/lib/libcrypto/util/mk1mf.pl +++ b/src/lib/libcrypto/util/mk1mf.pl | |||
@@ -1390,7 +1390,7 @@ sub read_options | |||
1390 | } | 1390 | } |
1391 | } | 1391 | } |
1392 | } | 1392 | } |
1393 | elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } | 1393 | elsif (/^([^=]*)=(.*)$/ && !/^-D/){ $VARS{$1}=$2; } |
1394 | elsif (/^-[lL].*$/) { $l_flags.="$_ "; } | 1394 | elsif (/^-[lL].*$/) { $l_flags.="$_ "; } |
1395 | elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) | 1395 | elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) |
1396 | { $c_flags.="$_ "; } | 1396 | { $c_flags.="$_ "; } |
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl new file mode 100644 index 0000000000..554bebb159 --- /dev/null +++ b/src/lib/libcrypto/util/mkerr.pl | |||
@@ -0,0 +1,715 @@ | |||
1 | #!/usr/local/bin/perl -w | ||
2 | |||
3 | my $config = "crypto/err/openssl.ec"; | ||
4 | my $debug = 0; | ||
5 | my $rebuild = 0; | ||
6 | my $static = 1; | ||
7 | my $recurse = 0; | ||
8 | my $reindex = 0; | ||
9 | my $dowrite = 0; | ||
10 | my $staticloader = ""; | ||
11 | |||
12 | my $pack_errcode; | ||
13 | my $load_errcode; | ||
14 | |||
15 | while (@ARGV) { | ||
16 | my $arg = $ARGV[0]; | ||
17 | if($arg eq "-conf") { | ||
18 | shift @ARGV; | ||
19 | $config = shift @ARGV; | ||
20 | } elsif($arg eq "-debug") { | ||
21 | $debug = 1; | ||
22 | shift @ARGV; | ||
23 | } elsif($arg eq "-rebuild") { | ||
24 | $rebuild = 1; | ||
25 | shift @ARGV; | ||
26 | } elsif($arg eq "-recurse") { | ||
27 | $recurse = 1; | ||
28 | shift @ARGV; | ||
29 | } elsif($arg eq "-reindex") { | ||
30 | $reindex = 1; | ||
31 | shift @ARGV; | ||
32 | } elsif($arg eq "-nostatic") { | ||
33 | $static = 0; | ||
34 | shift @ARGV; | ||
35 | } elsif($arg eq "-staticloader") { | ||
36 | $staticloader = "static "; | ||
37 | shift @ARGV; | ||
38 | } elsif($arg eq "-write") { | ||
39 | $dowrite = 1; | ||
40 | shift @ARGV; | ||
41 | } else { | ||
42 | last; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | if($recurse) { | ||
47 | @source = ( <crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>, | ||
48 | <fips/*.c>, <fips/*/*.c>); | ||
49 | } else { | ||
50 | @source = @ARGV; | ||
51 | } | ||
52 | |||
53 | # Read in the config file | ||
54 | |||
55 | open(IN, "<$config") || die "Can't open config file $config"; | ||
56 | |||
57 | # Parse config file | ||
58 | |||
59 | while(<IN>) | ||
60 | { | ||
61 | if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) { | ||
62 | $hinc{$1} = $2; | ||
63 | $libinc{$2} = $1; | ||
64 | $cskip{$3} = $1; | ||
65 | if($3 ne "NONE") { | ||
66 | $csrc{$1} = $3; | ||
67 | $fmax{$1} = 99; | ||
68 | $rmax{$1} = 99; | ||
69 | $fassigned{$1} = ":"; | ||
70 | $rassigned{$1} = ":"; | ||
71 | $fnew{$1} = 0; | ||
72 | $rnew{$1} = 0; | ||
73 | } | ||
74 | } elsif (/^F\s+(\S+)/) { | ||
75 | # Add extra function with $1 | ||
76 | } elsif (/^R\s+(\S+)\s+(\S+)/) { | ||
77 | $rextra{$1} = $2; | ||
78 | $rcodes{$1} = $2; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | close IN; | ||
83 | |||
84 | # Scan each header file in turn and make a list of error codes | ||
85 | # and function names | ||
86 | |||
87 | while (($hdr, $lib) = each %libinc) | ||
88 | { | ||
89 | next if($hdr eq "NONE"); | ||
90 | print STDERR "Scanning header file $hdr\n" if $debug; | ||
91 | my $line = "", $def= "", $linenr = 0, $gotfile = 0; | ||
92 | if (open(IN, "<$hdr")) { | ||
93 | $gotfile = 1; | ||
94 | while(<IN>) { | ||
95 | $linenr++; | ||
96 | print STDERR "line: $linenr\r" if $debug; | ||
97 | |||
98 | last if(/BEGIN\s+ERROR\s+CODES/); | ||
99 | if ($line ne '') { | ||
100 | $_ = $line . $_; | ||
101 | $line = ''; | ||
102 | } | ||
103 | |||
104 | if (/\\$/) { | ||
105 | $line = $_; | ||
106 | next; | ||
107 | } | ||
108 | |||
109 | if(/\/\*/) { | ||
110 | if (not /\*\//) { # multiline comment... | ||
111 | $line = $_; # ... just accumulate | ||
112 | next; | ||
113 | } else { | ||
114 | s/\/\*.*?\*\///gs; # wipe it | ||
115 | } | ||
116 | } | ||
117 | |||
118 | if ($cpp) { | ||
119 | $cpp++ if /^#\s*if/; | ||
120 | $cpp-- if /^#\s*endif/; | ||
121 | next; | ||
122 | } | ||
123 | $cpp = 1 if /^#.*ifdef.*cplusplus/; # skip "C" declaration | ||
124 | |||
125 | next if (/^\#/); # skip preprocessor directives | ||
126 | |||
127 | s/{[^{}]*}//gs; # ignore {} blocks | ||
128 | |||
129 | if (/\{|\/\*/) { # Add a } so editor works... | ||
130 | $line = $_; | ||
131 | } else { | ||
132 | $def .= $_; | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | print STDERR " \r" if $debug; | ||
138 | $defnr = 0; | ||
139 | # Delete any DECLARE_ macros | ||
140 | $def =~ s/DECLARE_\w+\([\w,\s]+\)//gs; | ||
141 | foreach (split /;/, $def) { | ||
142 | $defnr++; | ||
143 | print STDERR "def: $defnr\r" if $debug; | ||
144 | |||
145 | # The goal is to collect function names from function declarations. | ||
146 | |||
147 | s/^[\n\s]*//g; | ||
148 | s/[\n\s]*$//g; | ||
149 | |||
150 | # Skip over recognized non-function declarations | ||
151 | next if(/typedef\W/ or /DECLARE_STACK_OF/ or /TYPEDEF_.*_OF/); | ||
152 | |||
153 | # Remove STACK_OF(foo) | ||
154 | s/STACK_OF\(\w+\)/void/; | ||
155 | |||
156 | # Reduce argument lists to empty () | ||
157 | # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {} | ||
158 | while(/\(.*\)/s) { | ||
159 | s/\([^\(\)]+\)/\{\}/gs; | ||
160 | s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs; #(*f{}) -> f | ||
161 | } | ||
162 | # pretend as we didn't use curly braces: {} -> () | ||
163 | s/\{\}/\(\)/gs; | ||
164 | |||
165 | if (/(\w+)\s*\(\).*/s) { # first token prior [first] () is | ||
166 | my $name = $1; # a function name! | ||
167 | $name =~ tr/[a-z]/[A-Z]/; | ||
168 | $ftrans{$name} = $1; | ||
169 | } elsif (/[\(\)]/ and not (/=/)) { | ||
170 | print STDERR "Header $hdr: cannot parse: $_;\n"; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | print STDERR " \r" if $debug; | ||
175 | |||
176 | next if $reindex; | ||
177 | |||
178 | # Scan function and reason codes and store them: keep a note of the | ||
179 | # maximum code used. | ||
180 | |||
181 | if ($gotfile) { | ||
182 | while(<IN>) { | ||
183 | if(/^\#define\s+(\S+)\s+(\S+)/) { | ||
184 | $name = $1; | ||
185 | $code = $2; | ||
186 | next if $name =~ /^${lib}err/; | ||
187 | unless($name =~ /^${lib}_([RF])_(\w+)$/) { | ||
188 | print STDERR "Invalid error code $name\n"; | ||
189 | next; | ||
190 | } | ||
191 | if($1 eq "R") { | ||
192 | $rcodes{$name} = $code; | ||
193 | if ($rassigned{$lib} =~ /:$code:/) { | ||
194 | print STDERR "!! ERROR: $lib reason code $code assigned twice\n"; | ||
195 | } | ||
196 | $rassigned{$lib} .= "$code:"; | ||
197 | if(!(exists $rextra{$name}) && | ||
198 | ($code > $rmax{$lib}) ) { | ||
199 | $rmax{$lib} = $code; | ||
200 | } | ||
201 | } else { | ||
202 | if ($fassigned{$lib} =~ /:$code:/) { | ||
203 | print STDERR "!! ERROR: $lib function code $code assigned twice\n"; | ||
204 | } | ||
205 | $fassigned{$lib} .= "$code:"; | ||
206 | if($code > $fmax{$lib}) { | ||
207 | $fmax{$lib} = $code; | ||
208 | } | ||
209 | $fcodes{$name} = $code; | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | |||
215 | if ($debug) { | ||
216 | if (defined($fmax{$lib})) { | ||
217 | print STDERR "Max function code fmax" . "{" . "$lib" . "} = $fmax{$lib}\n"; | ||
218 | $fassigned{$lib} =~ m/^:(.*):$/; | ||
219 | @fassigned = sort {$a <=> $b} split(":", $1); | ||
220 | print STDERR " @fassigned\n"; | ||
221 | } | ||
222 | if (defined($rmax{$lib})) { | ||
223 | print STDERR "Max reason code rmax" . "{" . "$lib" . "} = $rmax{$lib}\n"; | ||
224 | $rassigned{$lib} =~ m/^:(.*):$/; | ||
225 | @rassigned = sort {$a <=> $b} split(":", $1); | ||
226 | print STDERR " @rassigned\n"; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | if ($lib eq "SSL") { | ||
231 | if ($rmax{$lib} >= 1000) { | ||
232 | print STDERR "!! ERROR: SSL error codes 1000+ are reserved for alerts.\n"; | ||
233 | print STDERR "!! Any new alerts must be added to $config.\n"; | ||
234 | print STDERR "\n"; | ||
235 | } | ||
236 | } | ||
237 | close IN; | ||
238 | } | ||
239 | |||
240 | # Scan each C source file and look for function and reason codes | ||
241 | # This is done by looking for strings that "look like" function or | ||
242 | # reason codes: basically anything consisting of all upper case and | ||
243 | # numerics which has _F_ or _R_ in it and which has the name of an | ||
244 | # error library at the start. This seems to work fine except for the | ||
245 | # oddly named structure BIO_F_CTX which needs to be ignored. | ||
246 | # If a code doesn't exist in list compiled from headers then mark it | ||
247 | # with the value "X" as a place holder to give it a value later. | ||
248 | # Store all function and reason codes found in %ufcodes and %urcodes | ||
249 | # so all those unreferenced can be printed out. | ||
250 | |||
251 | |||
252 | foreach $file (@source) { | ||
253 | # Don't parse the error source file. | ||
254 | next if exists $cskip{$file}; | ||
255 | print STDERR "File loaded: ".$file."\r" if $debug; | ||
256 | open(IN, "<$file") || die "Can't open source file $file\n"; | ||
257 | while(<IN>) { | ||
258 | if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) { | ||
259 | next unless exists $csrc{$2}; | ||
260 | next if($1 eq "BIO_F_BUFFER_CTX"); | ||
261 | $ufcodes{$1} = 1; | ||
262 | if(!exists $fcodes{$1}) { | ||
263 | $fcodes{$1} = "X"; | ||
264 | $fnew{$2}++; | ||
265 | } | ||
266 | $notrans{$1} = 1 unless exists $ftrans{$3}; | ||
267 | } | ||
268 | if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) { | ||
269 | next unless exists $csrc{$2}; | ||
270 | $urcodes{$1} = 1; | ||
271 | if(!exists $rcodes{$1}) { | ||
272 | $rcodes{$1} = "X"; | ||
273 | $rnew{$2}++; | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | close IN; | ||
278 | } | ||
279 | print STDERR " \n" if $debug; | ||
280 | |||
281 | # Now process each library in turn. | ||
282 | |||
283 | foreach $lib (keys %csrc) | ||
284 | { | ||
285 | my $hfile = $hinc{$lib}; | ||
286 | my $cfile = $csrc{$lib}; | ||
287 | if(!$fnew{$lib} && !$rnew{$lib}) { | ||
288 | print STDERR "$lib:\t\tNo new error codes\n"; | ||
289 | next unless $rebuild; | ||
290 | } else { | ||
291 | print STDERR "$lib:\t\t$fnew{$lib} New Functions,"; | ||
292 | print STDERR " $rnew{$lib} New Reasons.\n"; | ||
293 | next unless $dowrite; | ||
294 | } | ||
295 | |||
296 | # If we get here then we have some new error codes so we | ||
297 | # need to rebuild the header file and C file. | ||
298 | |||
299 | # Make a sorted list of error and reason codes for later use. | ||
300 | |||
301 | my @function = sort grep(/^${lib}_/,keys %fcodes); | ||
302 | my @reasons = sort grep(/^${lib}_/,keys %rcodes); | ||
303 | |||
304 | # Rewrite the header file | ||
305 | |||
306 | if (open(IN, "<$hfile")) { | ||
307 | # Copy across the old file | ||
308 | while(<IN>) { | ||
309 | push @out, $_; | ||
310 | last if (/BEGIN ERROR CODES/); | ||
311 | } | ||
312 | close IN; | ||
313 | } else { | ||
314 | push @out, | ||
315 | "/* ====================================================================\n", | ||
316 | " * Copyright (c) 2001-2008 The OpenSSL Project. All rights reserved.\n", | ||
317 | " *\n", | ||
318 | " * Redistribution and use in source and binary forms, with or without\n", | ||
319 | " * modification, are permitted provided that the following conditions\n", | ||
320 | " * are met:\n", | ||
321 | " *\n", | ||
322 | " * 1. Redistributions of source code must retain the above copyright\n", | ||
323 | " * notice, this list of conditions and the following disclaimer. \n", | ||
324 | " *\n", | ||
325 | " * 2. Redistributions in binary form must reproduce the above copyright\n", | ||
326 | " * notice, this list of conditions and the following disclaimer in\n", | ||
327 | " * the documentation and/or other materials provided with the\n", | ||
328 | " * distribution.\n", | ||
329 | " *\n", | ||
330 | " * 3. All advertising materials mentioning features or use of this\n", | ||
331 | " * software must display the following acknowledgment:\n", | ||
332 | " * \"This product includes software developed by the OpenSSL Project\n", | ||
333 | " * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n", | ||
334 | " *\n", | ||
335 | " * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n", | ||
336 | " * endorse or promote products derived from this software without\n", | ||
337 | " * prior written permission. For written permission, please contact\n", | ||
338 | " * openssl-core\@openssl.org.\n", | ||
339 | " *\n", | ||
340 | " * 5. Products derived from this software may not be called \"OpenSSL\"\n", | ||
341 | " * nor may \"OpenSSL\" appear in their names without prior written\n", | ||
342 | " * permission of the OpenSSL Project.\n", | ||
343 | " *\n", | ||
344 | " * 6. Redistributions of any form whatsoever must retain the following\n", | ||
345 | " * acknowledgment:\n", | ||
346 | " * \"This product includes software developed by the OpenSSL Project\n", | ||
347 | " * for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n", | ||
348 | " *\n", | ||
349 | " * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n", | ||
350 | " * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n", | ||
351 | " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n", | ||
352 | " * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n", | ||
353 | " * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n", | ||
354 | " * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n", | ||
355 | " * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n", | ||
356 | " * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n", | ||
357 | " * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n", | ||
358 | " * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n", | ||
359 | " * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n", | ||
360 | " * OF THE POSSIBILITY OF SUCH DAMAGE.\n", | ||
361 | " * ====================================================================\n", | ||
362 | " *\n", | ||
363 | " * This product includes cryptographic software written by Eric Young\n", | ||
364 | " * (eay\@cryptsoft.com). This product includes software written by Tim\n", | ||
365 | " * Hudson (tjh\@cryptsoft.com).\n", | ||
366 | " *\n", | ||
367 | " */\n", | ||
368 | "\n", | ||
369 | "#ifndef HEADER_${lib}_ERR_H\n", | ||
370 | "#define HEADER_${lib}_ERR_H\n", | ||
371 | "\n", | ||
372 | "/* BEGIN ERROR CODES */\n"; | ||
373 | } | ||
374 | open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n"; | ||
375 | |||
376 | print OUT @out; | ||
377 | undef @out; | ||
378 | print OUT <<"EOF"; | ||
379 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
380 | * made after this point may be overwritten when the script is next run. | ||
381 | */ | ||
382 | EOF | ||
383 | if($static) { | ||
384 | print OUT <<"EOF"; | ||
385 | ${staticloader}void ERR_load_${lib}_strings(void); | ||
386 | |||
387 | EOF | ||
388 | } else { | ||
389 | print OUT <<"EOF"; | ||
390 | ${staticloader}void ERR_load_${lib}_strings(void); | ||
391 | ${staticloader}void ERR_unload_${lib}_strings(void); | ||
392 | ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line); | ||
393 | #define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__) | ||
394 | |||
395 | EOF | ||
396 | } | ||
397 | print OUT <<"EOF"; | ||
398 | /* Error codes for the $lib functions. */ | ||
399 | |||
400 | /* Function codes. */ | ||
401 | EOF | ||
402 | |||
403 | foreach $i (@function) { | ||
404 | $z=6-int(length($i)/8); | ||
405 | if($fcodes{$i} eq "X") { | ||
406 | $fassigned{$lib} =~ m/^:([^:]*):/; | ||
407 | $findcode = $1; | ||
408 | if (!defined($findcode)) { | ||
409 | $findcode = $fmax{$lib}; | ||
410 | } | ||
411 | while ($fassigned{$lib} =~ m/:$findcode:/) { | ||
412 | $findcode++; | ||
413 | } | ||
414 | $fcodes{$i} = $findcode; | ||
415 | $fassigned{$lib} .= "$findcode:"; | ||
416 | print STDERR "New Function code $i\n" if $debug; | ||
417 | } | ||
418 | printf OUT "#define $i%s $fcodes{$i}\n","\t" x $z; | ||
419 | } | ||
420 | |||
421 | print OUT "\n/* Reason codes. */\n"; | ||
422 | |||
423 | foreach $i (@reasons) { | ||
424 | $z=6-int(length($i)/8); | ||
425 | if($rcodes{$i} eq "X") { | ||
426 | $rassigned{$lib} =~ m/^:([^:]*):/; | ||
427 | $findcode = $1; | ||
428 | if (!defined($findcode)) { | ||
429 | $findcode = $rmax{$lib}; | ||
430 | } | ||
431 | while ($rassigned{$lib} =~ m/:$findcode:/) { | ||
432 | $findcode++; | ||
433 | } | ||
434 | $rcodes{$i} = $findcode; | ||
435 | $rassigned{$lib} .= "$findcode:"; | ||
436 | print STDERR "New Reason code $i\n" if $debug; | ||
437 | } | ||
438 | printf OUT "#define $i%s $rcodes{$i}\n","\t" x $z; | ||
439 | } | ||
440 | print OUT <<"EOF"; | ||
441 | |||
442 | #ifdef __cplusplus | ||
443 | } | ||
444 | #endif | ||
445 | #endif | ||
446 | EOF | ||
447 | close OUT; | ||
448 | |||
449 | # Rewrite the C source file containing the error details. | ||
450 | |||
451 | # First, read any existing reason string definitions: | ||
452 | my %err_reason_strings; | ||
453 | if (open(IN,"<$cfile")) { | ||
454 | while (<IN>) { | ||
455 | if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) { | ||
456 | $err_reason_strings{$1} = $2; | ||
457 | } | ||
458 | } | ||
459 | close(IN); | ||
460 | } | ||
461 | |||
462 | my $hincf; | ||
463 | if($static) { | ||
464 | $hfile =~ /([^\/]+)$/; | ||
465 | $hincf = "<openssl/$1>"; | ||
466 | } else { | ||
467 | $hincf = "\"$hfile\""; | ||
468 | } | ||
469 | |||
470 | # If static we know the error code at compile time so use it | ||
471 | # in error definitions. | ||
472 | |||
473 | if ($static) | ||
474 | { | ||
475 | $pack_errcode = "ERR_LIB_${lib}"; | ||
476 | $load_errcode = "0"; | ||
477 | } | ||
478 | else | ||
479 | { | ||
480 | $pack_errcode = "0"; | ||
481 | $load_errcode = "ERR_LIB_${lib}"; | ||
482 | } | ||
483 | |||
484 | |||
485 | open (OUT,">$cfile") || die "Can't open $cfile for writing"; | ||
486 | |||
487 | print OUT <<"EOF"; | ||
488 | /* $cfile */ | ||
489 | /* ==================================================================== | ||
490 | * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. | ||
491 | * | ||
492 | * Redistribution and use in source and binary forms, with or without | ||
493 | * modification, are permitted provided that the following conditions | ||
494 | * are met: | ||
495 | * | ||
496 | * 1. Redistributions of source code must retain the above copyright | ||
497 | * notice, this list of conditions and the following disclaimer. | ||
498 | * | ||
499 | * 2. Redistributions in binary form must reproduce the above copyright | ||
500 | * notice, this list of conditions and the following disclaimer in | ||
501 | * the documentation and/or other materials provided with the | ||
502 | * distribution. | ||
503 | * | ||
504 | * 3. All advertising materials mentioning features or use of this | ||
505 | * software must display the following acknowledgment: | ||
506 | * "This product includes software developed by the OpenSSL Project | ||
507 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
508 | * | ||
509 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
510 | * endorse or promote products derived from this software without | ||
511 | * prior written permission. For written permission, please contact | ||
512 | * openssl-core\@OpenSSL.org. | ||
513 | * | ||
514 | * 5. Products derived from this software may not be called "OpenSSL" | ||
515 | * nor may "OpenSSL" appear in their names without prior written | ||
516 | * permission of the OpenSSL Project. | ||
517 | * | ||
518 | * 6. Redistributions of any form whatsoever must retain the following | ||
519 | * acknowledgment: | ||
520 | * "This product includes software developed by the OpenSSL Project | ||
521 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
522 | * | ||
523 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
524 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
525 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
526 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
527 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
528 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
529 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
530 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
531 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
532 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
533 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
534 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
535 | * ==================================================================== | ||
536 | * | ||
537 | * This product includes cryptographic software written by Eric Young | ||
538 | * (eay\@cryptsoft.com). This product includes software written by Tim | ||
539 | * Hudson (tjh\@cryptsoft.com). | ||
540 | * | ||
541 | */ | ||
542 | |||
543 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
544 | * made to it will be overwritten when the script next updates this file, | ||
545 | * only reason strings will be preserved. | ||
546 | */ | ||
547 | |||
548 | #include <stdio.h> | ||
549 | #include <openssl/err.h> | ||
550 | #include $hincf | ||
551 | |||
552 | /* BEGIN ERROR CODES */ | ||
553 | #ifndef OPENSSL_NO_ERR | ||
554 | |||
555 | #define ERR_FUNC(func) ERR_PACK($pack_errcode,func,0) | ||
556 | #define ERR_REASON(reason) ERR_PACK($pack_errcode,0,reason) | ||
557 | |||
558 | static ERR_STRING_DATA ${lib}_str_functs[]= | ||
559 | { | ||
560 | EOF | ||
561 | # Add each function code: if a function name is found then use it. | ||
562 | foreach $i (@function) { | ||
563 | my $fn; | ||
564 | $i =~ /^${lib}_F_(\S+)$/; | ||
565 | $fn = $1; | ||
566 | if(exists $ftrans{$fn}) { | ||
567 | $fn = $ftrans{$fn}; | ||
568 | } | ||
569 | # print OUT "{ERR_PACK($pack_errcode,$i,0),\t\"$fn\"},\n"; | ||
570 | print OUT "{ERR_FUNC($i),\t\"$fn\"},\n"; | ||
571 | } | ||
572 | print OUT <<"EOF"; | ||
573 | {0,NULL} | ||
574 | }; | ||
575 | |||
576 | static ERR_STRING_DATA ${lib}_str_reasons[]= | ||
577 | { | ||
578 | EOF | ||
579 | # Add each reason code. | ||
580 | foreach $i (@reasons) { | ||
581 | my $rn; | ||
582 | my $rstr = "ERR_REASON($i)"; | ||
583 | my $nspc = 0; | ||
584 | if (exists $err_reason_strings{$i}) { | ||
585 | $rn = $err_reason_strings{$i}; | ||
586 | } else { | ||
587 | $i =~ /^${lib}_R_(\S+)$/; | ||
588 | $rn = $1; | ||
589 | $rn =~ tr/_[A-Z]/ [a-z]/; | ||
590 | } | ||
591 | $nspc = 40 - length($rstr) unless length($rstr) > 40; | ||
592 | $nspc = " " x $nspc; | ||
593 | print OUT "{${rstr}${nspc},\"$rn\"},\n"; | ||
594 | } | ||
595 | if($static) { | ||
596 | print OUT <<"EOF"; | ||
597 | {0,NULL} | ||
598 | }; | ||
599 | |||
600 | #endif | ||
601 | |||
602 | ${staticloader}void ERR_load_${lib}_strings(void) | ||
603 | { | ||
604 | #ifndef OPENSSL_NO_ERR | ||
605 | |||
606 | if (ERR_func_error_string(${lib}_str_functs[0].error) == NULL) | ||
607 | { | ||
608 | ERR_load_strings($load_errcode,${lib}_str_functs); | ||
609 | ERR_load_strings($load_errcode,${lib}_str_reasons); | ||
610 | } | ||
611 | #endif | ||
612 | } | ||
613 | EOF | ||
614 | } else { | ||
615 | print OUT <<"EOF"; | ||
616 | {0,NULL} | ||
617 | }; | ||
618 | |||
619 | #endif | ||
620 | |||
621 | #ifdef ${lib}_LIB_NAME | ||
622 | static ERR_STRING_DATA ${lib}_lib_name[]= | ||
623 | { | ||
624 | {0 ,${lib}_LIB_NAME}, | ||
625 | {0,NULL} | ||
626 | }; | ||
627 | #endif | ||
628 | |||
629 | |||
630 | static int ${lib}_lib_error_code=0; | ||
631 | static int ${lib}_error_init=1; | ||
632 | |||
633 | ${staticloader}void ERR_load_${lib}_strings(void) | ||
634 | { | ||
635 | if (${lib}_lib_error_code == 0) | ||
636 | ${lib}_lib_error_code=ERR_get_next_error_library(); | ||
637 | |||
638 | if (${lib}_error_init) | ||
639 | { | ||
640 | ${lib}_error_init=0; | ||
641 | #ifndef OPENSSL_NO_ERR | ||
642 | ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs); | ||
643 | ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons); | ||
644 | #endif | ||
645 | |||
646 | #ifdef ${lib}_LIB_NAME | ||
647 | ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0); | ||
648 | ERR_load_strings(0,${lib}_lib_name); | ||
649 | #endif | ||
650 | } | ||
651 | } | ||
652 | |||
653 | ${staticloader}void ERR_unload_${lib}_strings(void) | ||
654 | { | ||
655 | if (${lib}_error_init == 0) | ||
656 | { | ||
657 | #ifndef OPENSSL_NO_ERR | ||
658 | ERR_unload_strings(${lib}_lib_error_code,${lib}_str_functs); | ||
659 | ERR_unload_strings(${lib}_lib_error_code,${lib}_str_reasons); | ||
660 | #endif | ||
661 | |||
662 | #ifdef ${lib}_LIB_NAME | ||
663 | ERR_unload_strings(0,${lib}_lib_name); | ||
664 | #endif | ||
665 | ${lib}_error_init=1; | ||
666 | } | ||
667 | } | ||
668 | |||
669 | ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line) | ||
670 | { | ||
671 | if (${lib}_lib_error_code == 0) | ||
672 | ${lib}_lib_error_code=ERR_get_next_error_library(); | ||
673 | ERR_PUT_error(${lib}_lib_error_code,function,reason,file,line); | ||
674 | } | ||
675 | EOF | ||
676 | |||
677 | } | ||
678 | |||
679 | close OUT; | ||
680 | undef %err_reason_strings; | ||
681 | } | ||
682 | |||
683 | if($debug && defined(%notrans)) { | ||
684 | print STDERR "The following function codes were not translated:\n"; | ||
685 | foreach(sort keys %notrans) | ||
686 | { | ||
687 | print STDERR "$_\n"; | ||
688 | } | ||
689 | } | ||
690 | |||
691 | # Make a list of unreferenced function and reason codes | ||
692 | |||
693 | foreach (keys %fcodes) { | ||
694 | push (@funref, $_) unless exists $ufcodes{$_}; | ||
695 | } | ||
696 | |||
697 | foreach (keys %rcodes) { | ||
698 | push (@runref, $_) unless exists $urcodes{$_}; | ||
699 | } | ||
700 | |||
701 | if($debug && defined(@funref) ) { | ||
702 | print STDERR "The following function codes were not referenced:\n"; | ||
703 | foreach(sort @funref) | ||
704 | { | ||
705 | print STDERR "$_\n"; | ||
706 | } | ||
707 | } | ||
708 | |||
709 | if($debug && defined(@runref) ) { | ||
710 | print STDERR "The following reason codes were not referenced:\n"; | ||
711 | foreach(sort @runref) | ||
712 | { | ||
713 | print STDERR "$_\n"; | ||
714 | } | ||
715 | } | ||
diff --git a/src/lib/libcrypto/util/mkstack.pl b/src/lib/libcrypto/util/mkstack.pl new file mode 100644 index 0000000000..2a968f395f --- /dev/null +++ b/src/lib/libcrypto/util/mkstack.pl | |||
@@ -0,0 +1,126 @@ | |||
1 | #!/usr/local/bin/perl -w | ||
2 | |||
3 | # This is a utility that searches out "DECLARE_STACK_OF()" | ||
4 | # declarations in .h and .c files, and updates/creates/replaces | ||
5 | # the corresponding macro declarations in crypto/stack/safestack.h. | ||
6 | # As it's not generally possible to have macros that generate macros, | ||
7 | # we need to control this from the "outside", here in this script. | ||
8 | # | ||
9 | # Geoff Thorpe, June, 2000 (with massive Perl-hacking | ||
10 | # help from Steve Robb) | ||
11 | |||
12 | my $safestack = "crypto/stack/safestack"; | ||
13 | |||
14 | my $do_write; | ||
15 | while (@ARGV) { | ||
16 | my $arg = $ARGV[0]; | ||
17 | if($arg eq "-write") { | ||
18 | $do_write = 1; | ||
19 | } | ||
20 | shift @ARGV; | ||
21 | } | ||
22 | |||
23 | |||
24 | @source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>); | ||
25 | foreach $file (@source) { | ||
26 | next if -l $file; | ||
27 | |||
28 | # Open the .c/.h file for reading | ||
29 | open(IN, "< $file") || die "Can't open $file for reading: $!"; | ||
30 | |||
31 | while(<IN>) { | ||
32 | if (/^DECLARE_STACK_OF\(([^)]+)\)/) { | ||
33 | push @stacklst, $1; | ||
34 | } if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) { | ||
35 | push @asn1setlst, $1; | ||
36 | } if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) { | ||
37 | push @p12stklst, $1; | ||
38 | } | ||
39 | } | ||
40 | close(IN); | ||
41 | } | ||
42 | |||
43 | |||
44 | |||
45 | my $old_stackfile = ""; | ||
46 | my $new_stackfile = ""; | ||
47 | my $inside_block = 0; | ||
48 | my $type_thing; | ||
49 | |||
50 | open(IN, "< $safestack.h") || die "Can't open input file: $!"; | ||
51 | while(<IN>) { | ||
52 | $old_stackfile .= $_; | ||
53 | |||
54 | if (m|^/\* This block of defines is updated by util/mkstack.pl, please do not touch! \*/|) { | ||
55 | $inside_block = 1; | ||
56 | } | ||
57 | if (m|^/\* End of util/mkstack.pl block, you may now edit :-\) \*/|) { | ||
58 | $inside_block = 0; | ||
59 | } elsif ($inside_block == 0) { | ||
60 | $new_stackfile .= $_; | ||
61 | } | ||
62 | next if($inside_block != 1); | ||
63 | $new_stackfile .= "/* This block of defines is updated by util/mkstack.pl, please do not touch! */"; | ||
64 | |||
65 | foreach $type_thing (sort @stacklst) { | ||
66 | $new_stackfile .= <<EOF; | ||
67 | |||
68 | #define sk_${type_thing}_new(st) SKM_sk_new($type_thing, (st)) | ||
69 | #define sk_${type_thing}_new_null() SKM_sk_new_null($type_thing) | ||
70 | #define sk_${type_thing}_free(st) SKM_sk_free($type_thing, (st)) | ||
71 | #define sk_${type_thing}_num(st) SKM_sk_num($type_thing, (st)) | ||
72 | #define sk_${type_thing}_value(st, i) SKM_sk_value($type_thing, (st), (i)) | ||
73 | #define sk_${type_thing}_set(st, i, val) SKM_sk_set($type_thing, (st), (i), (val)) | ||
74 | #define sk_${type_thing}_zero(st) SKM_sk_zero($type_thing, (st)) | ||
75 | #define sk_${type_thing}_push(st, val) SKM_sk_push($type_thing, (st), (val)) | ||
76 | #define sk_${type_thing}_unshift(st, val) SKM_sk_unshift($type_thing, (st), (val)) | ||
77 | #define sk_${type_thing}_find(st, val) SKM_sk_find($type_thing, (st), (val)) | ||
78 | #define sk_${type_thing}_find_ex(st, val) SKM_sk_find_ex($type_thing, (st), (val)) | ||
79 | #define sk_${type_thing}_delete(st, i) SKM_sk_delete($type_thing, (st), (i)) | ||
80 | #define sk_${type_thing}_delete_ptr(st, ptr) SKM_sk_delete_ptr($type_thing, (st), (ptr)) | ||
81 | #define sk_${type_thing}_insert(st, val, i) SKM_sk_insert($type_thing, (st), (val), (i)) | ||
82 | #define sk_${type_thing}_set_cmp_func(st, cmp) SKM_sk_set_cmp_func($type_thing, (st), (cmp)) | ||
83 | #define sk_${type_thing}_dup(st) SKM_sk_dup($type_thing, st) | ||
84 | #define sk_${type_thing}_pop_free(st, free_func) SKM_sk_pop_free($type_thing, (st), (free_func)) | ||
85 | #define sk_${type_thing}_shift(st) SKM_sk_shift($type_thing, (st)) | ||
86 | #define sk_${type_thing}_pop(st) SKM_sk_pop($type_thing, (st)) | ||
87 | #define sk_${type_thing}_sort(st) SKM_sk_sort($type_thing, (st)) | ||
88 | #define sk_${type_thing}_is_sorted(st) SKM_sk_is_sorted($type_thing, (st)) | ||
89 | EOF | ||
90 | } | ||
91 | foreach $type_thing (sort @asn1setlst) { | ||
92 | $new_stackfile .= <<EOF; | ||
93 | |||
94 | #define d2i_ASN1_SET_OF_${type_thing}(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\ | ||
95 | SKM_ASN1_SET_OF_d2i($type_thing, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) | ||
96 | #define i2d_ASN1_SET_OF_${type_thing}(st, pp, i2d_func, ex_tag, ex_class, is_set) \\ | ||
97 | SKM_ASN1_SET_OF_i2d($type_thing, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) | ||
98 | #define ASN1_seq_pack_${type_thing}(st, i2d_func, buf, len) \\ | ||
99 | SKM_ASN1_seq_pack($type_thing, (st), (i2d_func), (buf), (len)) | ||
100 | #define ASN1_seq_unpack_${type_thing}(buf, len, d2i_func, free_func) \\ | ||
101 | SKM_ASN1_seq_unpack($type_thing, (buf), (len), (d2i_func), (free_func)) | ||
102 | EOF | ||
103 | } | ||
104 | foreach $type_thing (sort @p12stklst) { | ||
105 | $new_stackfile .= <<EOF; | ||
106 | |||
107 | #define PKCS12_decrypt_d2i_${type_thing}(algor, d2i_func, free_func, pass, passlen, oct, seq) \\ | ||
108 | SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) | ||
109 | EOF | ||
110 | } | ||
111 | $new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n"; | ||
112 | $inside_block = 2; | ||
113 | } | ||
114 | |||
115 | |||
116 | if ($new_stackfile eq $old_stackfile) { | ||
117 | print "No changes to $safestack.h.\n"; | ||
118 | exit 0; # avoid unnecessary rebuild | ||
119 | } | ||
120 | |||
121 | if ($do_write) { | ||
122 | print "Writing new $safestack.h.\n"; | ||
123 | open OUT, ">$safestack.h" || die "Can't open output file"; | ||
124 | print OUT $new_stackfile; | ||
125 | close OUT; | ||
126 | } | ||
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl index 85121c8ed1..166785db8d 100644 --- a/src/lib/libcrypto/util/pl/VC-32.pl +++ b/src/lib/libcrypto/util/pl/VC-32.pl | |||
@@ -164,7 +164,7 @@ if ($FLAVOR =~ /NT/) | |||
164 | $ex_libs="unicows.lib $ex_libs"; | 164 | $ex_libs="unicows.lib $ex_libs"; |
165 | } | 165 | } |
166 | # static library stuff | 166 | # static library stuff |
167 | $mklib='lib /nologo'; | 167 | $mklib='lib'; |
168 | $ranlib=''; | 168 | $ranlib=''; |
169 | $plib=""; | 169 | $plib=""; |
170 | $libp=".lib"; | 170 | $libp=".lib"; |
@@ -184,7 +184,7 @@ if ($nasm) { | |||
184 | $asm.=' /Zi' if $debug; | 184 | $asm.=' /Zi' if $debug; |
185 | $afile='/Fo'; | 185 | $afile='/Fo'; |
186 | } else { | 186 | } else { |
187 | $asm='ml /nologo /Cp /coff /c /Cx'; | 187 | $asm='ml /Cp /coff /c /Cx'; |
188 | $asm.=" /Zi" if $debug; | 188 | $asm.=" /Zi" if $debug; |
189 | $afile='/Fo'; | 189 | $afile='/Fo'; |
190 | } | 190 | } |
@@ -307,7 +307,6 @@ sub do_lib_rule | |||
307 | $name =~ tr/a-z/A-Z/; | 307 | $name =~ tr/a-z/A-Z/; |
308 | $name = "/def:ms/${name}.def"; | 308 | $name = "/def:ms/${name}.def"; |
309 | } | 309 | } |
310 | |||
311 | # $target="\$(LIB_D)$o$target"; | 310 | # $target="\$(LIB_D)$o$target"; |
312 | # $ret.="$target: $objs\n"; | 311 | # $ret.="$target: $objs\n"; |
313 | if (!$shlib) | 312 | if (!$shlib) |
@@ -405,7 +404,7 @@ sub do_link_rule | |||
405 | if ($standalone == 1) | 404 | if ($standalone == 1) |
406 | { | 405 | { |
407 | $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t"; | 406 | $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t"; |
408 | $ret.= "\$(EX_LIBS) " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild); | 407 | $ret.= "$mwex advapi32.lib " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild); |
409 | $ret.="$files $libs\n<<\n"; | 408 | $ret.="$files $libs\n<<\n"; |
410 | } | 409 | } |
411 | elsif ($standalone == 2) | 410 | elsif ($standalone == 2) |
diff --git a/src/lib/libcrypto/util/pl/netware.pl b/src/lib/libcrypto/util/pl/netware.pl new file mode 100644 index 0000000000..173c9919f2 --- /dev/null +++ b/src/lib/libcrypto/util/pl/netware.pl | |||
@@ -0,0 +1,526 @@ | |||
1 | # Metrowerks Codewarrior or gcc / nlmconv for NetWare | ||
2 | # | ||
3 | |||
4 | $version_header = "crypto/opensslv.h"; | ||
5 | open(IN, "$version_header") or die "Couldn't open $version_header: $!"; | ||
6 | while (<IN>) { | ||
7 | if (/^#define[\s\t]+OPENSSL_VERSION_NUMBER[\s\t]+0x(\d)(\d{2})(\d{2})(\d{2})/) | ||
8 | { | ||
9 | # die "OpenSSL version detected: $1.$2.$3.$4\n"; | ||
10 | #$nlmvernum = "$1,$2,$3"; | ||
11 | $nlmvernum = "$1,".($2*10+$3).",".($4*1); | ||
12 | #$nlmverstr = "$1.".($2*1).".".($3*1).($4?(chr(96+$4)):""); | ||
13 | break; | ||
14 | } | ||
15 | } | ||
16 | close(IN) or die "Couldn't close $version_header: $!"; | ||
17 | |||
18 | $readme_file = "README"; | ||
19 | open(IN, $readme_file) or die "Couldn't open $readme_file: $!"; | ||
20 | while (<IN>) { | ||
21 | if (/^[\s\t]+OpenSSL[\s\t]+(\d)\.(\d{1,2})\.(\d{1,2})([a-z])(.*)/) | ||
22 | { | ||
23 | #$nlmvernum = "$1,$2,$3"; | ||
24 | #$nlmvernum = "$1,".($2*10+$3).",".($4*1); | ||
25 | $nlmverstr = "$1.$2.$3$4$5"; | ||
26 | } | ||
27 | elsif (/^[\s\t]+(Copyright \(c\) \d{4}\-\d{4} The OpenSSL Project)$/) | ||
28 | { | ||
29 | $nlmcpystr = $1; | ||
30 | } | ||
31 | break if ($nlmvernum && $nlmcpystr); | ||
32 | } | ||
33 | close(IN) or die "Couldn't close $readme_file: $!"; | ||
34 | |||
35 | # Define stacksize here | ||
36 | $nlmstack = "32768"; | ||
37 | |||
38 | # some default settings here in case we failed to find them in README | ||
39 | $nlmvernum = "1,0,0" if (!$nlmvernum); | ||
40 | $nlmverstr = "OpenSSL" if (!$nlmverstr); | ||
41 | $nlmcpystr = "Copyright (c) 1998-now The OpenSSL Project" if (!$nlmcpystr); | ||
42 | |||
43 | # die "OpenSSL copyright: $nlmcpystr\nOpenSSL verstring: $nlmverstr\nOpenSSL vernumber: $nlmvernum\n"; | ||
44 | |||
45 | # The import files and other misc imports needed to link | ||
46 | @misc_imports = ("GetProcessSwitchCount", "RunningProcess", | ||
47 | "GetSuperHighResolutionTimer"); | ||
48 | if ($LIBC) | ||
49 | { | ||
50 | @import_files = ("libc.imp"); | ||
51 | @module_files = ("libc"); | ||
52 | $libarch = "LIBC"; | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | # clib build | ||
57 | @import_files = ("clib.imp"); | ||
58 | push(@import_files, "socklib.imp") if ($BSDSOCK); | ||
59 | @module_files = ("clib"); | ||
60 | # push(@misc_imports, "_rt_modu64%16", "_rt_divu64%16"); | ||
61 | $libarch = "CLIB"; | ||
62 | } | ||
63 | if ($BSDSOCK) | ||
64 | { | ||
65 | $libarch .= "-BSD"; | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | $libarch .= "-WS2"; | ||
70 | push(@import_files, "ws2nlm.imp"); | ||
71 | } | ||
72 | |||
73 | # The "IMPORTS" environment variable must be set and point to the location | ||
74 | # where import files (*.imp) can be found. | ||
75 | # Example: set IMPORTS=c:\ndk\nwsdk\imports | ||
76 | $import_path = $ENV{"IMPORTS"} || die ("IMPORTS environment variable not set\n"); | ||
77 | |||
78 | |||
79 | # The "PRELUDE" environment variable must be set and point to the location | ||
80 | # and name of the prelude source to link with ( nwpre.obj is recommended ). | ||
81 | # Example: set PRELUDE=c:\codewar\novell support\metrowerks support\libraries\runtime\nwpre.obj | ||
82 | $prelude = $ENV{"PRELUDE"} || die ("PRELUDE environment variable not set\n"); | ||
83 | |||
84 | # The "INCLUDES" environment variable must be set and point to the location | ||
85 | # where import files (*.imp) can be found. | ||
86 | $include_path = $ENV{"INCLUDE"} || die ("INCLUDES environment variable not set\n"); | ||
87 | $include_path =~ s/\\/\//g; | ||
88 | $include_path = join(" -I", split(/;/, $include_path)); | ||
89 | |||
90 | # check for gcc compiler | ||
91 | $gnuc = $ENV{"GNUC"}; | ||
92 | |||
93 | #$ssl= "ssleay32"; | ||
94 | #$crypto="libeay32"; | ||
95 | |||
96 | if ($gnuc) | ||
97 | { | ||
98 | # C compiler | ||
99 | $cc='gcc'; | ||
100 | # Linker | ||
101 | $link='nlmconv'; | ||
102 | # librarian | ||
103 | $mklib='ar'; | ||
104 | $o='/'; | ||
105 | # cp command | ||
106 | $cp='cp -af'; | ||
107 | # rm command | ||
108 | $rm='rm -f'; | ||
109 | # mv command | ||
110 | $mv='mv -f'; | ||
111 | # mkdir command | ||
112 | $mkdir='gmkdir'; | ||
113 | #$ranlib='ranlib'; | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | # C compiler | ||
118 | $cc='mwccnlm'; | ||
119 | # Linker | ||
120 | $link='mwldnlm'; | ||
121 | # librarian | ||
122 | $mklib='mwldnlm'; | ||
123 | # Path separator | ||
124 | $o='\\'; | ||
125 | # cp command | ||
126 | $cp='copy >nul:'; | ||
127 | # rm command | ||
128 | $rm='del /f /q'; | ||
129 | } | ||
130 | |||
131 | # assembler | ||
132 | if ($nw_nasm) | ||
133 | { | ||
134 | if ($gnuc) | ||
135 | { | ||
136 | $asm="nasmw -s -f elf"; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | $asm="nasmw -s -f coff"; | ||
141 | } | ||
142 | $afile="-o "; | ||
143 | $asm.=" -g" if $debug; | ||
144 | } | ||
145 | elsif ($nw_mwasm) | ||
146 | { | ||
147 | $asm="mwasmnlm -maxerrors 20"; | ||
148 | $afile="-o "; | ||
149 | $asm.=" -g" if $debug; | ||
150 | } | ||
151 | elsif ($nw_masm) | ||
152 | { | ||
153 | # masm assembly settings - it should be possible to use masm but haven't | ||
154 | # got it working. | ||
155 | # $asm='ml /Cp /coff /c /Cx'; | ||
156 | # $asm.=" /Zi" if $debug; | ||
157 | # $afile='/Fo'; | ||
158 | die("Support for masm assembler not yet functional\n"); | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | $asm=""; | ||
163 | $afile=""; | ||
164 | } | ||
165 | |||
166 | |||
167 | |||
168 | if ($gnuc) | ||
169 | { | ||
170 | # compile flags for GNUC | ||
171 | # additional flags based upon debug | non-debug | ||
172 | if ($debug) | ||
173 | { | ||
174 | $cflags="-g -DDEBUG"; | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | $cflags="-O2"; | ||
179 | } | ||
180 | $cflags.=" -nostdinc -I$include_path \\ | ||
181 | -fno-builtin -fpcc-struct-return -fno-strict-aliasing \\ | ||
182 | -funsigned-char -Wall -Wno-unused -Wno-uninitialized"; | ||
183 | |||
184 | # link flags | ||
185 | $lflags="-T"; | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | # compile flags for CodeWarrior | ||
190 | # additional flags based upon debug | non-debug | ||
191 | if ($debug) | ||
192 | { | ||
193 | $cflags="-opt off -g -sym internal -DDEBUG"; | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | # CodeWarrior compiler has a problem with optimizations for floating | ||
198 | # points - no optimizations until further investigation | ||
199 | # $cflags="-opt all"; | ||
200 | } | ||
201 | |||
202 | # NOTES: Several c files in the crypto subdirectory include headers from | ||
203 | # their local directories. Metrowerks wouldn't find these h files | ||
204 | # without adding individual include directives as compile flags | ||
205 | # or modifying the c files. Instead of adding individual include | ||
206 | # paths for each subdirectory a recursive include directive | ||
207 | # is used ( -ir crypto ). | ||
208 | # | ||
209 | # A similar issue exists for the engines and apps subdirectories. | ||
210 | # | ||
211 | # Turned off the "possible" warnings ( -w nopossible ). Metrowerks | ||
212 | # complained a lot about various stuff. May want to turn back | ||
213 | # on for further development. | ||
214 | $cflags.=" -nostdinc -ir crypto -ir engines -ir apps -I$include_path \\ | ||
215 | -msgstyle gcc -align 4 -processor pentium -char unsigned \\ | ||
216 | -w on -w nolargeargs -w nopossible -w nounusedarg -w nounusedexpr \\ | ||
217 | -w noimplicitconv -relax_pointers -nosyspath -maxerrors 20"; | ||
218 | |||
219 | # link flags | ||
220 | $lflags="-msgstyle gcc -zerobss -nostdlib -sym internal -commandfile"; | ||
221 | } | ||
222 | |||
223 | # common defines | ||
224 | $cflags.=" -DL_ENDIAN -DOPENSSL_SYSNAME_NETWARE -U_WIN32"; | ||
225 | |||
226 | # If LibC build add in NKS_LIBC define and set the entry/exit | ||
227 | # routines - The default entry/exit routines are for CLib and don't exist | ||
228 | # in LibC | ||
229 | if ($LIBC) | ||
230 | { | ||
231 | $cflags.=" -DNETWARE_LIBC"; | ||
232 | $nlmstart = "_LibCPrelude"; | ||
233 | $nlmexit = "_LibCPostlude"; | ||
234 | @nlm_flags = ("pseudopreemption", "flag_on 64"); | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | $cflags.=" -DNETWARE_CLIB"; | ||
239 | $nlmstart = "_Prelude"; | ||
240 | $nlmexit = "_Stop"; | ||
241 | } | ||
242 | |||
243 | # If BSD Socket support is requested, set a define for the compiler | ||
244 | if ($BSDSOCK) | ||
245 | { | ||
246 | $cflags.=" -DNETWARE_BSDSOCK"; | ||
247 | if (!$LIBC) | ||
248 | { | ||
249 | $cflags.=" -DNETDB_USE_INTERNET"; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | |||
254 | # linking stuff | ||
255 | # for the output directories use the mk1mf.pl values with "_nw" appended | ||
256 | if ($shlib) | ||
257 | { | ||
258 | if ($LIBC) | ||
259 | { | ||
260 | $out_def.="_nw_libc_nlm"; | ||
261 | $tmp_def.="_nw_libc_nlm"; | ||
262 | $inc_def.="_nw_libc_nlm"; | ||
263 | } | ||
264 | else # NETWARE_CLIB | ||
265 | { | ||
266 | $out_def.="_nw_clib_nlm"; | ||
267 | $tmp_def.="_nw_clib_nlm"; | ||
268 | $inc_def.="_nw_clib_nlm"; | ||
269 | } | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | if ($gnuc) # GNUC Tools | ||
274 | { | ||
275 | $libp=".a"; | ||
276 | $shlibp=".a"; | ||
277 | $lib_flags="-cr"; | ||
278 | } | ||
279 | else # CodeWarrior | ||
280 | { | ||
281 | $libp=".lib"; | ||
282 | $shlibp=".lib"; | ||
283 | $lib_flags="-nodefaults -type library -o"; | ||
284 | } | ||
285 | if ($LIBC) | ||
286 | { | ||
287 | $out_def.="_nw_libc"; | ||
288 | $tmp_def.="_nw_libc"; | ||
289 | $inc_def.="_nw_libc"; | ||
290 | } | ||
291 | else # NETWARE_CLIB | ||
292 | { | ||
293 | $out_def.="_nw_clib"; | ||
294 | $tmp_def.="_nw_clib"; | ||
295 | $inc_def.="_nw_clib"; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | # used by mk1mf.pl | ||
300 | $obj='.o'; | ||
301 | $ofile='-o '; | ||
302 | $efile=''; | ||
303 | $exep='.nlm'; | ||
304 | $ex_libs=''; | ||
305 | |||
306 | if (!$no_asm) | ||
307 | { | ||
308 | $bn_asm_obj="\$(OBJ_D)${o}bn-nw${obj}"; | ||
309 | $bn_asm_src="crypto${o}bn${o}asm${o}bn-nw.asm"; | ||
310 | $bnco_asm_obj="\$(OBJ_D)${o}co-nw${obj}"; | ||
311 | $bnco_asm_src="crypto${o}bn${o}asm${o}co-nw.asm"; | ||
312 | $aes_asm_obj="\$(OBJ_D)${o}a-nw${obj}"; | ||
313 | $aes_asm_src="crypto${o}aes${o}asm${o}a-nw.asm"; | ||
314 | $des_enc_obj="\$(OBJ_D)${o}d-nw${obj} \$(OBJ_D)${o}y-nw${obj}"; | ||
315 | $des_enc_src="crypto${o}des${o}asm${o}d-nw.asm crypto${o}des${o}asm${o}y-nw.asm"; | ||
316 | $bf_enc_obj="\$(OBJ_D)${o}b-nw${obj}"; | ||
317 | $bf_enc_src="crypto${o}bf${o}asm${o}b-nw.asm"; | ||
318 | $cast_enc_obj="\$(OBJ_D)${o}c-nw${obj}"; | ||
319 | $cast_enc_src="crypto${o}cast${o}asm${o}c-nw.asm"; | ||
320 | $rc4_enc_obj="\$(OBJ_D)${o}r4-nw${obj}"; | ||
321 | $rc4_enc_src="crypto${o}rc4${o}asm${o}r4-nw.asm"; | ||
322 | $rc5_enc_obj="\$(OBJ_D)${o}r5-nw${obj}"; | ||
323 | $rc5_enc_src="crypto${o}rc5${o}asm${o}r5-nw.asm"; | ||
324 | $md5_asm_obj="\$(OBJ_D)${o}m5-nw${obj}"; | ||
325 | $md5_asm_src="crypto${o}md5${o}asm${o}m5-nw.asm"; | ||
326 | $sha1_asm_obj="\$(OBJ_D)${o}s1-nw${obj}"; | ||
327 | $sha1_asm_src="crypto${o}sha${o}asm${o}s1-nw.asm"; | ||
328 | $rmd160_asm_obj="\$(OBJ_D)${o}rm-nw${obj}"; | ||
329 | $rmd160_asm_src="crypto${o}ripemd${o}asm${o}rm-nw.asm"; | ||
330 | $cpuid_asm_obj="\$(OBJ_D)${o}x86cpuid-nw${obj}"; | ||
331 | $cpuid_asm_src="crypto${o}x86cpuid-nw.asm"; | ||
332 | $cflags.=" -DOPENSSL_CPUID_OBJ -DBN_ASM -DOPENSSL_BN_ASM_PART_WORDS -DMD5_ASM -DSHA1_ASM"; | ||
333 | $cflags.=" -DAES_ASM -DRMD160_ASM"; | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | $bn_asm_obj=''; | ||
338 | $bn_asm_src=''; | ||
339 | $bnco_asm_obj=''; | ||
340 | $bnco_asm_src=''; | ||
341 | $aes_asm_obj=''; | ||
342 | $aes_asm_src=''; | ||
343 | $des_enc_obj=''; | ||
344 | $des_enc_src=''; | ||
345 | $bf_enc_obj=''; | ||
346 | $bf_enc_src=''; | ||
347 | $cast_enc_obj=''; | ||
348 | $cast_enc_src=''; | ||
349 | $rc4_enc_obj=''; | ||
350 | $rc4_enc_src=''; | ||
351 | $rc5_enc_obj=''; | ||
352 | $rc5_enc_src=''; | ||
353 | $md5_asm_obj=''; | ||
354 | $md5_asm_src=''; | ||
355 | $sha1_asm_obj=''; | ||
356 | $sha1_asm_src=''; | ||
357 | $rmd160_asm_obj=''; | ||
358 | $rmd160_asm_src=''; | ||
359 | $cpuid_asm_obj=''; | ||
360 | $cpuid_asm_src=''; | ||
361 | } | ||
362 | |||
363 | # create the *.def linker command files in \openssl\netware\ directory | ||
364 | sub do_def_file | ||
365 | { | ||
366 | # strip off the leading path | ||
367 | my($target) = bname(shift); | ||
368 | my($i); | ||
369 | |||
370 | if ($target =~ /(.*).nlm/) | ||
371 | { | ||
372 | $target = $1; | ||
373 | } | ||
374 | |||
375 | # special case for openssl - the mk1mf.pl defines E_EXE = openssl | ||
376 | if ($target =~ /E_EXE/) | ||
377 | { | ||
378 | $target =~ s/\$\(E_EXE\)/openssl/; | ||
379 | } | ||
380 | |||
381 | # Note: originally tried to use full path ( \openssl\netware\$target.def ) | ||
382 | # Metrowerks linker choked on this with an assertion failure. bug??? | ||
383 | # | ||
384 | my($def_file) = "netware${o}$target.def"; | ||
385 | |||
386 | open(DEF_OUT, ">$def_file") || die("unable to open file $def_file\n"); | ||
387 | |||
388 | print( DEF_OUT "# command file generated by netware.pl for NLM target.\n" ); | ||
389 | print( DEF_OUT "# do not edit this file - all your changes will be lost!!\n" ); | ||
390 | print( DEF_OUT "#\n"); | ||
391 | print( DEF_OUT "DESCRIPTION \"$target ($libarch) - OpenSSL $nlmverstr\"\n"); | ||
392 | print( DEF_OUT "COPYRIGHT \"$nlmcpystr\"\n"); | ||
393 | print( DEF_OUT "VERSION $nlmvernum\n"); | ||
394 | print( DEF_OUT "STACK $nlmstack\n"); | ||
395 | print( DEF_OUT "START $nlmstart\n"); | ||
396 | print( DEF_OUT "EXIT $nlmexit\n"); | ||
397 | |||
398 | # special case for openssl | ||
399 | if ($target eq "openssl") | ||
400 | { | ||
401 | print( DEF_OUT "SCREENNAME \"OpenSSL $nlmverstr\"\n"); | ||
402 | } | ||
403 | else | ||
404 | { | ||
405 | print( DEF_OUT "SCREENNAME \"DEFAULT\"\n"); | ||
406 | } | ||
407 | |||
408 | foreach $i (@misc_imports) | ||
409 | { | ||
410 | print( DEF_OUT "IMPORT $i\n"); | ||
411 | } | ||
412 | |||
413 | foreach $i (@import_files) | ||
414 | { | ||
415 | print( DEF_OUT "IMPORT \@$import_path${o}$i\n"); | ||
416 | } | ||
417 | |||
418 | foreach $i (@module_files) | ||
419 | { | ||
420 | print( DEF_OUT "MODULE $i\n"); | ||
421 | } | ||
422 | |||
423 | foreach $i (@nlm_flags) | ||
424 | { | ||
425 | print( DEF_OUT "$i\n"); | ||
426 | } | ||
427 | |||
428 | if ($gnuc) | ||
429 | { | ||
430 | if ($target =~ /openssl/) | ||
431 | { | ||
432 | print( DEF_OUT "INPUT ${tmp_def}${o}openssl${obj}\n"); | ||
433 | print( DEF_OUT "INPUT ${tmp_def}${o}openssl${libp}\n"); | ||
434 | } | ||
435 | else | ||
436 | { | ||
437 | print( DEF_OUT "INPUT ${tmp_def}${o}${target}${obj}\n"); | ||
438 | } | ||
439 | print( DEF_OUT "INPUT $prelude\n"); | ||
440 | print( DEF_OUT "INPUT ${out_def}${o}${ssl}${libp} ${out_def}${o}${crypto}${libp}\n"); | ||
441 | print( DEF_OUT "OUTPUT $target.nlm\n"); | ||
442 | } | ||
443 | |||
444 | close(DEF_OUT); | ||
445 | return($def_file); | ||
446 | } | ||
447 | |||
448 | sub do_lib_rule | ||
449 | { | ||
450 | my($objs,$target,$name,$shlib)=@_; | ||
451 | my($ret); | ||
452 | |||
453 | $ret.="$target: $objs\n"; | ||
454 | if (!$shlib) | ||
455 | { | ||
456 | $ret.="\t\@echo Building Lib: $name\n"; | ||
457 | $ret.="\t\$(MKLIB) $lib_flags $target $objs\n"; | ||
458 | $ret.="\t\@echo .\n" | ||
459 | } | ||
460 | else | ||
461 | { | ||
462 | die( "Building as NLM not currently supported!" ); | ||
463 | } | ||
464 | |||
465 | $ret.="\n"; | ||
466 | return($ret); | ||
467 | } | ||
468 | |||
469 | sub do_link_rule | ||
470 | { | ||
471 | my($target,$files,$dep_libs,$libs)=@_; | ||
472 | my($ret); | ||
473 | my($def_file) = do_def_file($target); | ||
474 | |||
475 | $ret.="$target: $files $dep_libs\n"; | ||
476 | |||
477 | # NOTE: When building the test nlms no screen name is given | ||
478 | # which causes the console screen to be used. By using the console | ||
479 | # screen there is no "<press any key to continue>" message which | ||
480 | # requires user interaction. The test script ( do_tests.pl ) needs | ||
481 | # to be able to run the tests without requiring user interaction. | ||
482 | # | ||
483 | # However, the sample program "openssl.nlm" is used by the tests and is | ||
484 | # a interactive sample so a screen is desired when not be run by the | ||
485 | # tests. To solve the problem, two versions of the program are built: | ||
486 | # openssl2 - no screen used by tests | ||
487 | # openssl - default screen - use for normal interactive modes | ||
488 | # | ||
489 | |||
490 | # special case for openssl - the mk1mf.pl defines E_EXE = openssl | ||
491 | if ($target =~ /E_EXE/) | ||
492 | { | ||
493 | my($target2) = $target; | ||
494 | |||
495 | $target2 =~ s/\(E_EXE\)/\(E_EXE\)2/; | ||
496 | |||
497 | # openssl2 | ||
498 | my($def_file2) = do_def_file($target2); | ||
499 | |||
500 | if ($gnuc) | ||
501 | { | ||
502 | $ret.="\t\$(MKLIB) $lib_flags \$(TMP_D)${o}\$(E_EXE).a \$(filter-out \$(TMP_D)${o}\$(E_EXE)${obj},$files)\n"; | ||
503 | $ret.="\t\$(LINK) \$(LFLAGS) $def_file2\n"; | ||
504 | $ret.="\t\@$mv \$(E_EXE)2.nlm \$(TEST_D)\n"; | ||
505 | } | ||
506 | else | ||
507 | { | ||
508 | $ret.="\t\$(LINK) \$(LFLAGS) $def_file2 $files \"$prelude\" $libs -o $target2\n"; | ||
509 | } | ||
510 | } | ||
511 | if ($gnuc) | ||
512 | { | ||
513 | $ret.="\t\$(LINK) \$(LFLAGS) $def_file\n"; | ||
514 | $ret.="\t\@$mv \$(\@F) \$(TEST_D)\n"; | ||
515 | } | ||
516 | else | ||
517 | { | ||
518 | $ret.="\t\$(LINK) \$(LFLAGS) $def_file $files \"$prelude\" $libs -o $target\n"; | ||
519 | } | ||
520 | |||
521 | $ret.="\n"; | ||
522 | return($ret); | ||
523 | |||
524 | } | ||
525 | |||
526 | 1; | ||