Codebase list libcryptx-perl / cd4184a
tuning libtom-update Karel Miko 5 years ago
4 changed file(s) with 65 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
3939 ^.travis*
4040 t/openssl/.*$
4141 ^src/liballinone*
42 ^src/update-makefiles.pl$
42 ^src/update-libtom.pl$
100100 } if $^O eq 'MSWin32' && $Config{cc} =~ /gcc/;
101101
102102 $extra_targets .= q{
103 update-libtom:
104 $(NOECHO) perl src/update-libtom.pl
103105 versionsync:
104106 $(NOECHO) perl _generators/version_patch.pl sync
105107 versioninc:
0 #!/usr/bin/env perl
1
2 use Modern::Perl;
3 use File::Find qw(find);
4 use File::Slurper qw(read_text write_text);
5 use FindBin;
6
7 my $ltc_branch = "pr/pkcs8-improved";
8 my $ltm_branch = "no-stdint-h";
9 my $tmpdir = "/tmp/libtom.git.checkout.$$";
10
11 warn "update libtommath from github (branch: $ltm_branch)..\n";
12 system "rm -rf $tmpdir; mkdir $tmpdir";
13 system "git clone -b $ltm_branch https://github.com/libtom/libtommath.git $tmpdir && cp -R $tmpdir/bn*.c $tmpdir/tom*.h $FindBin::Bin/ltm/ && echo ok";
14
15 warn "update libtomcrypt from github (branch: $ltc_branch)..\n";
16 system "rm -rf $tmpdir; mkdir $tmpdir";
17 system "git clone -b $ltc_branch https://github.com/libtom/libtomcrypt.git $tmpdir && cp -R $tmpdir/src/* $FindBin::Bin/ltc/ && echo ok";
18 system "rm -rf $tmpdir";
19
20 ### another style
21 #system "wget https://github.com/libtom/libtomcrypt/tarball/$ltc_branch -q -O - | tar xz --wildcards --transform 's,^libtom.*/src/,,' -C '$FindBin::Bin/ltc' 'libtom*/src/*'";
22 #system "wget https://github.com/libtom/libtommath/tarball/$ltm_branch -q -O - | tar xz --wildcards --transform 's,^libtom.*/,,' -C '$FindBin::Bin/ltm' 'libtom*/bn*.c' 'libtom*/tom*.h'";
23
24 warn "gonna remove unwanted..\n";
25 system 'rm', '-rf', "$FindBin::Bin/ltc/encauth/ocb/";
26 system 'rm', '-rf', "$FindBin::Bin/ltc/modes/f8/";
27 system 'rm', '-rf', "$FindBin::Bin/ltc/modes/lrw/";
28 system 'rm', '-rf', "$FindBin::Bin/ltc/modes/xts/";
29 system 'rm', '-rf', "$FindBin::Bin/ltc/pk/katja/";
30 system 'rm', '-rf', "$FindBin::Bin/ltc/math/gmp_desc.c";
31
32 ### get rid of bn_mp_set_long_long + bn_mp_get_long_long
33 system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_set_long_long.c";
34 system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_get_long_long.c";
35 system 'sed', '-i', 's,^\(int *mp_set_long_long.*\),/* \1 */,', 'src//ltm/tommath.h';
36 system 'sed', '-i', 's,^\(unsigned *long *long *mp_get_long_long.*\),/* \1 */,', 'src//ltm/tommath.h';
37
38 ### MSVC hack required for VC6 compatibility
39 # #ifdef _MSC_VER
40 # typedef unsigned __int64 mp_word
41 # #else
42 # typedef unsigned long long mp_word;
43 # #endif
44 system 'sed', '-i', 's,^\(typedef *unsigned *long *long *mp_word;\)$,#ifdef _MSC_VER\ntypedef unsigned __int64 mp_word;\n#else\n\1 /* PATCHED */\n#endif,', 'src//ltm/tommath.h';
45
46 find({ wanted=>sub { unlink $_ if -f $_ && $_ =~ /test\.c$/ && $_ !~ /sha3_test.c$/ }, no_chdir=>1 }, "$FindBin::Bin/ltc");
47 find({ wanted=>sub { unlink $_ if -f $_ && $_ =~ /\.o$/ }, no_chdir=>1 }, "$FindBin::Bin/ltm", "$FindBin::Bin/ltc");
48
49 #fix modes
50 warn "gonna chmod..\n";
51 find({ wanted=>sub { system "chmod -x $_" if -f $_ && -x $_ && $_ =~ /\.(c|h)/ }, no_chdir=>1 }, "$FindBin::Bin/ltm", "$FindBin::Bin/ltc");
52
53 my @objs = ();
54 find({ wanted=>sub { push @objs, $_ if $_ =~ /\.c$/ && $_ !~ /tab\.c$/}, no_chdir=>1 }, "$FindBin::Bin/ltc");
55 find({ wanted=>sub { push @objs, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, "$FindBin::Bin/ltm");
56
57 my $o = "OBJS=" . (join " ", map { s/\.c$/.o/r } map { s!^.*/(ltm|ltc)/!$1/!r } @objs) =~ s/(.{80}) /$1 \\\n/gr;
58 my $obj = "OBJS=" . (join " ", map { s/\.c$/.obj/r } map { s!^.*/(ltm|ltc)/!$1/!r } @objs) =~ s/(.{80}) /$1 \\\n/gr;
59
60 write_text("$FindBin::Bin/Makefile", read_text("$FindBin::Bin/Makefile") =~ s/OBJS=.+?\.o\n/$o\n/sr);
61 write_text("$FindBin::Bin/Makefile.nmake", read_text("$FindBin::Bin/Makefile.nmake") =~ s/OBJS=.+?\.obj\n/$obj\n/sr);
+0
-45
src/update-makefiles.pl less more
0 #!/usr/bin/env perl
1
2 use Modern::Perl;
3 use File::Find qw(find);
4 use File::Slurper qw(read_text write_text);
5 use FindBin;
6
7 warn "gonna remove unwanted..\n";
8 system 'rm', '-rf', "$FindBin::Bin/ltc/encauth/ocb/";
9 system 'rm', '-rf', "$FindBin::Bin/ltc/modes/f8/";
10 system 'rm', '-rf', "$FindBin::Bin/ltc/modes/lrw/";
11 system 'rm', '-rf', "$FindBin::Bin/ltc/modes/xts/";
12 system 'rm', '-rf', "$FindBin::Bin/ltc/pk/katja/";
13 system 'rm', '-rf', "$FindBin::Bin/ltc/math/gmp_desc.c";
14
15 ### get rid of bn_mp_set_long_long + bn_mp_get_long_long
16 system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_set_long_long.c";
17 system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_get_long_long.c";
18 system 'sed', '-i', 's,^\(int *mp_set_long_long.*\),/* \1 */,', 'src//ltm/tommath.h';
19 system 'sed', '-i', 's,^\(unsigned *long *long *mp_get_long_long.*\),/* \1 */,', 'src//ltm/tommath.h';
20
21 ### MSVC hack required for VC6 compatibility
22 # #ifdef _MSC_VER
23 # typedef unsigned __int64 mp_word
24 # #else
25 # typedef unsigned long long mp_word;
26 # #endif
27 system 'sed', '-i', 's,^\(typedef *unsigned *long *long *mp_word;\)$,#ifdef _MSC_VER\ntypedef unsigned __int64 mp_word;\n#else\n\1 /* PATCHED */\n#endif,', 'src//ltm/tommath.h';
28
29 find({ wanted=>sub { unlink $_ if -f $_ && $_ =~ /test\.c$/ && $_ !~ /sha3_test.c$/ }, no_chdir=>1 }, "$FindBin::Bin/ltc");
30 find({ wanted=>sub { unlink $_ if -f $_ && $_ =~ /\.o$/ }, no_chdir=>1 }, "$FindBin::Bin/ltm", "$FindBin::Bin/ltc");
31
32 #fix modes
33 warn "gonna chmod..\n";
34 find({ wanted=>sub { system "chmod -x $_" if -f $_ && -x $_ && $_ =~ /\.(c|h)/ }, no_chdir=>1 }, "$FindBin::Bin/ltm", "$FindBin::Bin/ltc");
35
36 my @objs = ();
37 find({ wanted=>sub { push @objs, $_ if $_ =~ /\.c$/ && $_ !~ /tab\.c$/}, no_chdir=>1 }, "$FindBin::Bin/ltc");
38 find({ wanted=>sub { push @objs, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, "$FindBin::Bin/ltm");
39
40 my $o = "OBJS=" . (join " ", map { s/\.c$/.o/r } map { s!^.*/(ltm|ltc)/!$1/!r } @objs) =~ s/(.{80}) /$1 \\\n/gr;
41 my $obj = "OBJS=" . (join " ", map { s/\.c$/.obj/r } map { s!^.*/(ltm|ltc)/!$1/!r } @objs) =~ s/(.{80}) /$1 \\\n/gr;
42
43 write_text("$FindBin::Bin/Makefile", read_text("$FindBin::Bin/Makefile") =~ s/OBJS=.+?\.o\n/$o\n/sr);
44 write_text("$FindBin::Bin/Makefile.nmake", read_text("$FindBin::Bin/Makefile.nmake") =~ s/OBJS=.+?\.obj\n/$obj\n/sr);