Mercurial > dropbear
annotate libtomcrypt/helper.pl @ 1863:b550845e500b
Use venv for test_aslr
Otherwise we can't find the psutil dependency
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 30 Jan 2022 13:37:20 +0800 |
parents | 6dba84798cd5 |
children |
rev | line source |
---|---|
1471
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 #!/usr/bin/env perl |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
3 use strict; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
4 use warnings; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
5 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
6 use Getopt::Long; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
7 use File::Find 'find'; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
8 use File::Basename 'basename'; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
9 use File::Glob 'bsd_glob'; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
10 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 sub read_file { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
12 my $f = shift; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
13 open my $fh, "<", $f or die "FATAL: read_rawfile() cannot open file '$f': $!"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
14 binmode $fh; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
15 return do { local $/; <$fh> }; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
16 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
17 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
18 sub write_file { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
19 my ($f, $data) = @_; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
20 die "FATAL: write_file() no data" unless defined $data; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
21 open my $fh, ">", $f or die "FATAL: write_file() cannot open file '$f': $!"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
22 binmode $fh; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
23 print $fh $data or die "FATAL: write_file() cannot write to '$f': $!"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
24 close $fh or die "FATAL: write_file() cannot close '$f': $!"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 return; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
26 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
28 sub check_source { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
29 my @all_files = (bsd_glob("makefile*"), bsd_glob("*.sh"), bsd_glob("*.pl")); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
30 find({ wanted=>sub { push @all_files, $_ if -f $_ }, no_chdir=>1 }, qw/src tests demos/); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
31 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
32 my $fails = 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 for my $file (sort @all_files) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
34 next unless $file =~ /\.(c|h|pl|py|sh)$/ || basename($file) =~ /^makefile/i; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
35 my $troubles = {}; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 my $lineno = 1; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
37 my $content = read_file($file); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
38 push @{$troubles->{crlf_line_end}}, '?' if $content =~ /\r/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
39 for my $l (split /\n/, $content) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
40 push @{$troubles->{merge_conflict}}, $lineno if $l =~ /^(<<<<<<<|=======|>>>>>>>)([^<=>]|$)/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
41 push @{$troubles->{trailing_space}}, $lineno if $l =~ / $/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
42 push @{$troubles->{tab}}, $lineno if $l =~ /\t/ && basename($file) !~ /^makefile/i; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
43 push @{$troubles->{non_ascii_char}}, $lineno if $l =~ /[^[:ascii:]]/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
44 push @{$troubles->{cpp_comment}}, $lineno if $file =~ /\.(c|h)$/ && ($l =~ /\s\/\// || $l =~ /\/\/\s/); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
45 # in ./src we prefer using XMEMCPY, XMALLOC, XFREE ... |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
46 push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bmemcpy\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
47 push @{$troubles->{unwanted_malloc}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bmalloc\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
48 push @{$troubles->{unwanted_realloc}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\brealloc\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
49 push @{$troubles->{unwanted_calloc}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bcalloc\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
50 push @{$troubles->{unwanted_free}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bfree\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
51 push @{$troubles->{unwanted_memset}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bmemset\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
52 push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bmemcpy\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
53 push @{$troubles->{unwanted_memmove}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bmemmove\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
54 push @{$troubles->{unwanted_memcmp}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bmemcmp\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
55 push @{$troubles->{unwanted_strcmp}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bstrcmp\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
56 push @{$troubles->{unwanted_clock}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bclock\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
57 push @{$troubles->{unwanted_qsort}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bqsort\s*\(/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
58 push @{$troubles->{sizeof_no_brackets}}, $lineno if $file =~ /^src\/.*\.c$/ && $l =~ /\bsizeof\s*[^\(]/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
59 if ($file =~ m|src/.*\.c$| && |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
60 $file !~ m|src/ciphers/.*\.c$| && |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
61 $file !~ m|src/hashes/.*\.c$| && |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
62 $file !~ m|src/math/.+_desc.c$| && |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
63 $file !~ m|src/stream/sober128/sober128_stream.c$| && |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
64 $l =~ /^static(\s+[a-zA-Z0-9_]+)+\s+([^_][a-zA-Z0-9_]+)\s*\(/) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
65 push @{$troubles->{staticfunc_name}}, "$lineno($2)"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
66 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
67 $lineno++; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
68 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
69 for my $k (sort keys %$troubles) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
70 warn "[$k] $file line:" . join(",", @{$troubles->{$k}}) . "\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
71 $fails++; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
72 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
73 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
74 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
75 warn( $fails > 0 ? "check-source: FAIL $fails\n" : "check-source: PASS\n" ); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
76 return $fails; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
77 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
78 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
79 sub check_defines { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
80 my $fails = 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
81 my $cust_h = read_file("src/headers/tomcrypt_custom.h"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
82 my $cryp_c = read_file("src/misc/crypt/crypt.c"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
83 $cust_h =~ s|/\*.*?\*/||sg; # remove comments |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
84 $cryp_c =~ s|/\*.*?\*/||sg; # remove comments |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
85 my %def = map { $_ => 1 } map { my $x = $_; $x =~ s/^\s*#define\s+(LTC_\S+).*$/$1/; $x } grep { /^\s*#define\s+LTC_\S+/ } split /\n/, $cust_h; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
86 for my $d (sort keys %def) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
87 next if $d =~ /^LTC_(DH\d+|ECC\d+|ECC_\S+|MPI|MUTEX_\S+\(x\)|NO_\S+)$/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
88 warn "$d missing in src/misc/crypt/crypt.c\n" and $fails++ if $cryp_c !~ /\Q$d\E/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
89 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
90 warn( $fails > 0 ? "check-defines: FAIL $fails\n" : "check-defines: PASS\n" ); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
91 return $fails; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
93 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
94 sub check_descriptor { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
95 my $which = shift; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
96 my $what = shift; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
97 my @src; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
98 my @descriptors; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 find({ wanted => sub { push @src, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, "./src/${which}/"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 for my $f (@src) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 my @n = map { my $x = $_; $x =~ s/^.*?ltc_${what}_descriptor\s+(\S+).*$/$1/; $x } grep { $_ =~ /ltc_${what}_descriptor/ } split /\n/, read_file($f); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 push @descriptors, @n if @n; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
104 my $fails = 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
105 for my $d (@descriptors) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
106 for my $f ("./src/misc/crypt/crypt_register_all_${which}.c") { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
107 my $txt = read_file($f); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
108 warn "$d missing in $f\n" and $fails++ if $txt !~ /\Q$d\E/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
109 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
110 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
111 for my $d (@descriptors) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
112 for my $f ("./tests/test.c") { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
113 my $txt = read_file($f); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
114 warn "$d missing in $f\n" and $fails++ if $txt !~ /\Q$d\E/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
115 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
116 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
117 my $name = sprintf("%-17s", "check-${which}:"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
118 warn( $fails > 0 ? "${name}FAIL $fails\n" : "${name}PASS\n" ); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
119 return $fails; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
120 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
121 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
122 sub check_descriptors { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
123 my $fails = 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
124 $fails = $fails + check_descriptor("ciphers", "cipher"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
125 $fails = $fails + check_descriptor("hashes", "hash"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
126 $fails = $fails + check_descriptor("prngs", "prng"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
127 return $fails; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
128 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
129 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
130 sub check_comments { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
131 my $fails = 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
132 my $first_comment = <<'MARKER'; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
133 /* LibTomCrypt, modular cryptographic library -- Tom St Denis |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
134 * |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
135 * LibTomCrypt is a library that provides various cryptographic |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
136 * algorithms in a highly modular and flexible manner. |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
137 * |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
138 * The library is free for all purposes without any express |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
139 * guarantee it works. |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
140 */ |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
141 MARKER |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
142 my $last_comment = <<'MARKER'; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
143 /* ref: $Format:%D$ */ |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
144 /* git commit: $Format:%H$ */ |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
145 /* commit time: $Format:%ai$ */ |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
146 MARKER |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
147 my @all_files; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
148 find({ wanted=> sub { push @all_files, $_ if $_ =~ /\.(c|h)$/ }, no_chdir=>1 }, 'demos', 'src', 'tests'); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
149 for my $f (@all_files) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
150 my $txt = read_file($f); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
151 if ($txt !~ /^\Q$first_comment\E/s) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
152 warn "[first_comment] $f\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
153 $fails++; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
154 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
155 if ($txt !~ /\Q$last_comment\E\s*$/s) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
156 warn "[last_comment] $f\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
157 $fails++; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
158 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
159 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
160 warn( $fails > 0 ? "check-comments: FAIL $fails\n" : "check-comments: PASS\n" ); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
161 return $fails; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
162 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
163 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
164 sub prepare_variable { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
165 my ($varname, @list) = @_; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
166 my $output = "$varname="; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
167 my $len = length($output); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
168 foreach my $obj (sort @list) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
169 $len = $len + length $obj; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
170 $obj =~ s/\*/\$/; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
171 if ($len > 100) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
172 $output .= "\\\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
173 $len = length $obj; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
174 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
175 $output .= $obj . ' '; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
176 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
177 $output =~ s/ $//; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
178 return $output; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
179 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
180 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
181 sub prepare_msvc_files_xml { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
182 my ($all, $exclude_re, $targets) = @_; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
183 my $last = []; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
184 my $depth = 2; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
185 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
186 # sort files in the same order as visual studio (ugly, I know) |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
187 my @parts = (); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
188 for my $orig (@$all) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
189 my $p = $orig; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
190 $p =~ s|/|/~|g; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
191 $p =~ s|/~([^/]+)$|/$1|g; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
192 # now we have: 'src/pk/rsa/rsa_verify_hash.c' > 'src/~pk/~rsa/rsa_verify_hash.c' |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
193 my @l = map { sprintf "% -99s", $_ } split /\//, $p; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
194 push @parts, [ $orig, join(':', @l) ]; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
195 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
196 my @sorted = map { $_->[0] } sort { $a->[1] cmp $b->[1] } @parts; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
197 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
198 my $files = "<Files>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
199 for my $full (@sorted) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
200 my @items = split /\//, $full; # split by '/' |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
201 $full =~ s|/|\\|g; # replace '/' bt '\' |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
202 shift @items; # drop first one (src) |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
203 pop @items; # drop last one (filename.ext) |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
204 my $current = \@items; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
205 if (join(':', @$current) ne join(':', @$last)) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
206 my $common = 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
207 $common++ while ($last->[$common] && $current->[$common] && $last->[$common] eq $current->[$common]); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
208 my $back = @$last - $common; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
209 if ($back > 0) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
210 $files .= ("\t" x --$depth) . "</Filter>\r\n" for (1..$back); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
211 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
212 my $fwd = [ @$current ]; splice(@$fwd, 0, $common); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
213 for my $i (0..scalar(@$fwd) - 1) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
214 $files .= ("\t" x $depth) . "<Filter\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
215 $files .= ("\t" x $depth) . "\tName=\"$fwd->[$i]\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
216 $files .= ("\t" x $depth) . "\t>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
217 $depth++; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
218 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
219 $last = $current; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
220 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
221 $files .= ("\t" x $depth) . "<File\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
222 $files .= ("\t" x $depth) . "\tRelativePath=\"$full\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
223 $files .= ("\t" x $depth) . "\t>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
224 if ($full =~ $exclude_re) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
225 for (@$targets) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
226 $files .= ("\t" x $depth) . "\t<FileConfiguration\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
227 $files .= ("\t" x $depth) . "\t\tName=\"$_\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
228 $files .= ("\t" x $depth) . "\t\tExcludedFromBuild=\"true\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
229 $files .= ("\t" x $depth) . "\t\t>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
230 $files .= ("\t" x $depth) . "\t\t<Tool\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
231 $files .= ("\t" x $depth) . "\t\t\tName=\"VCCLCompilerTool\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
232 $files .= ("\t" x $depth) . "\t\t\tAdditionalIncludeDirectories=\"\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
233 $files .= ("\t" x $depth) . "\t\t\tPreprocessorDefinitions=\"\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
234 $files .= ("\t" x $depth) . "\t\t/>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
235 $files .= ("\t" x $depth) . "\t</FileConfiguration>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
236 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
237 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
238 ########### aes_enc "hack" disabled - discussion: https://github.com/libtom/libtomcrypt/pull/158 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
239 # if ($full eq 'src\ciphers\aes\aes.c') { #hack |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
240 # my %cmd = ( |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
241 # 'Debug|Win32' => [ 'Debug/aes.obj;Debug/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/aes_enc.obj" /Fd"Debug/" /FD /GZ /c $(InputPath)
' ], |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
242 # 'Release|Win32' => [ 'Release/aes.obj;Release/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/" /Fd"Release/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/aes_enc.obj" /Fd"Release/" /FD /GZ /c $(InputPath)
' ], |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
243 # ); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
244 # for (@$targets) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
245 # next unless $cmd{$_}; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
246 # $files .= ("\t" x $depth) . "\t<FileConfiguration\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
247 # $files .= ("\t" x $depth) . "\t\tName=\"$_\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
248 # $files .= ("\t" x $depth) . "\t\t>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
249 # $files .= ("\t" x $depth) . "\t\t<Tool\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
250 # $files .= ("\t" x $depth) . "\t\t\tName=\"VCCustomBuildTool\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
251 # $files .= ("\t" x $depth) . "\t\t\tCommandLine=\"$cmd{$_}[1]\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
252 # $files .= ("\t" x $depth) . "\t\t\tOutputs=\"$cmd{$_}[0]\"\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
253 # $files .= ("\t" x $depth) . "\t\t/>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
254 # $files .= ("\t" x $depth) . "\t</FileConfiguration>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
255 # } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
256 # } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
257 $files .= ("\t" x $depth) . "</File>\r\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
258 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
259 $files .= ("\t" x --$depth) . "</Filter>\r\n" for (@$last); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
260 $files .= "\t</Files>"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
261 return $files; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
262 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
263 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
264 sub patch_file { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
265 my ($content, @variables) = @_; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
266 for my $v (@variables) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
267 if ($v =~ /^([A-Z0-9_]+)\s*=.*$/si) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
268 my $name = $1; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
269 $content =~ s/\n\Q$name\E\b.*?[^\\]\n/\n$v\n/s; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
270 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
271 else { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
272 die "patch_file failed: " . substr($v, 0, 30) . ".."; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
273 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
274 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
275 return $content; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
276 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
277 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
278 sub version_from_tomcrypt_h { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
279 my $h = read_file(shift); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
280 if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)\.([0-9]+)(.*)"/s) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
281 return "VERSION_PC=$1.$2.$3", "VERSION_LT=1:1", "VERSION=$1.$2.$3$4", "PROJECT_NUMBER=$1.$2.$3$4"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
282 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
283 else { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
284 die "#define SCRYPT not found in tomcrypt.h"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
285 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
286 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
287 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
288 sub process_makefiles { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
289 my $write = shift; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
290 my $changed_count = 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
291 my @c = (); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
292 find({ no_chdir => 1, wanted => sub { push @c, $_ if -f $_ && $_ =~ /\.c$/ && $_ !~ /tab.c$/ } }, 'src'); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
293 my @h = (); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
294 find({ no_chdir => 1, wanted => sub { push @h, $_ if -f $_ && $_ =~ /\.h$/ && $_ !~ /dh_static.h$/ } }, 'src'); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
295 my @all = (); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
296 find({ no_chdir => 1, wanted => sub { push @all, $_ if -f $_ && $_ =~ /\.(c|h)$/ } }, 'src'); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
297 my @t = qw(); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
298 find({ no_chdir => 1, wanted => sub { push @t, $_ if $_ =~ /(common|no_prng|_tests?|test).c$/ } }, 'tests'); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
299 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
300 my @o = sort ('src/ciphers/aes/aes_enc.o', map { my $x = $_; $x =~ s/\.c$/.o/; $x } @c); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
301 my $var_o = prepare_variable("OBJECTS", @o); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
302 my $var_h = prepare_variable("HEADERS", (sort @h)); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
303 (my $var_obj = $var_o) =~ s/\.o\b/.obj/sg; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
304 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
305 my $var_to = prepare_variable("TOBJECTS", sort map { my $x = $_; $x =~ s/\.c$/.o/; $x } @t); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
306 (my $var_tobj = $var_to) =~ s/\.o\b/.obj/sg; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
307 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
308 my @ver_version = version_from_tomcrypt_h("src/headers/tomcrypt.h"); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
309 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
310 # update MSVC project files |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
311 my $msvc_files = prepare_msvc_files_xml(\@all, qr/tab\.c$/, ['Debug|Win32', 'Release|Win32', 'Debug|x64', 'Release|x64']); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
312 for my $m (qw/libtomcrypt_VS2008.vcproj/) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
313 my $old = read_file($m); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
314 my $new = $old; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
315 $new =~ s|<Files>.*</Files>|$msvc_files|s; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
316 if ($old ne $new) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
317 write_file($m, $new) if $write; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
318 warn "changed: $m\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
319 $changed_count++; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
320 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
321 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
322 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
323 # update OBJECTS + HEADERS in makefile* |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
324 for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile_include.mk doc\/Doxyfile /) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
325 my $old = read_file($m); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
326 my $new = $m eq 'makefile.msvc' ? patch_file($old, $var_obj, $var_h, $var_tobj, @ver_version) |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
327 : patch_file($old, $var_o, $var_h, $var_to, @ver_version); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
328 if ($old ne $new) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
329 write_file($m, $new) if $write; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
330 warn "changed: $m\n"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
331 $changed_count++; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
332 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
333 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
334 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
335 if ($write) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
336 return 0; # no failures |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
337 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
338 else { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
339 warn( $changed_count > 0 ? "check-makefiles: FAIL $changed_count\n" : "check-makefiles: PASS\n" ); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
340 return $changed_count; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
341 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
342 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
343 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
344 sub die_usage { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
345 die <<"MARKER"; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
346 usage: $0 -s OR $0 --check-source |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
347 $0 -c OR $0 --check-descriptors |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
348 $0 -d OR $0 --check-defines |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
349 $0 -o OR $0 --check-comments |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
350 $0 -m OR $0 --check-makefiles |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
351 $0 -a OR $0 --check-all |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
352 $0 -u OR $0 --update-makefiles |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
353 $0 --fixupind crypt.ind |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
354 MARKER |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
355 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
356 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
357 GetOptions( "s|check-source" => \my $check_source, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
358 "c|check-descriptors" => \my $check_descriptors, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
359 "d|check-defines" => \my $check_defines, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
360 "o|check-comments" => \my $check_comments, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
361 "m|check-makefiles" => \my $check_makefiles, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
362 "a|check-all" => \my $check_all, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
363 "u|update-makefiles" => \my $update_makefiles, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
364 "f|fixupind=s" => \my $fixupind, |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
365 "h|help" => \my $help |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
366 ) or die_usage; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
367 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
368 if ($fixupind) { |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
369 my $txt = read_file($fixupind); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
370 $txt =~ s/^([^\n]*\n)/$1\n\\addcontentsline{toc}{chapter}{Index}\n/s; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
371 write_file($fixupind, $txt); |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
372 exit 0; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
373 } |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
374 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
375 my $failure; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
376 $failure ||= check_source() if $check_all || $check_source; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
377 $failure ||= check_defines() if $check_all || $check_defines; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
378 $failure ||= check_descriptors() if $check_all || $check_descriptors; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
379 $failure ||= check_comments() if $check_all || $check_comments; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
380 $failure ||= process_makefiles(0) if $check_all || $check_makefiles; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
381 $failure ||= process_makefiles(1) if $update_makefiles; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
382 |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
383 die_usage unless defined $failure; |
6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
384 exit $failure ? 1 : 0; |