diff options
author | Richard Levitte <levitte@openssl.org> | 2016-02-12 00:34:40 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-02-12 04:42:22 +0100 |
commit | fb3e2a88eed124b1a74ebed89c20283780ee2bc6 (patch) | |
tree | 00e3cb0532ca436a3c11c83a750cdfa7013e4558 /apps/progs.pl | |
parent | b3ca51559b1a6cd80dc179ee54613f00190d1cb4 (diff) | |
download | openssl-new-fb3e2a88eed124b1a74ebed89c20283780ee2bc6.tar.gz |
Generate progs.h from a bunch of files instead of internal knowledge
apps/progs.pl counted on the caller to provide the exact command
files. The unified build doesn't have that knowledge, and the easier
and more flexible thing to do is to feed it all the apps/*.c files and
let it figure out the command names by looking inside (looking for
/int ([a-z0-9][a-z0-9_]*)_main\(int argc,/).
Also, add it to the generate command, since it's a versioned file.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'apps/progs.pl')
-rw-r--r-- | apps/progs.pl | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/apps/progs.pl b/apps/progs.pl index 40053a7306..b87aef610e 100644 --- a/apps/progs.pl +++ b/apps/progs.pl @@ -1,5 +1,23 @@ -#!/usr/local/bin/perl -# Generate progs.h file from list of "programs" passed on the command line. +#!/usr/bin/perl +# Generate progs.h file by looking for command mains in list of C files +# passed on the command line. + +use strict; +use warnings; + +my %commands = (); +my $cmdre = qr/^\s*int\s+([a-z_][a-z0-9_]*)_main\(\s*int\s+argc\s*,/; + +foreach my $filename (@ARGV) { + open F, $filename or die "Coudn't open $_: $!\n"; + foreach (grep /$cmdre/, <F>) { + my @foo = /$cmdre/; + $commands{$1} = 1; + } + close F; +} + +@ARGV = sort keys %commands; print <<'EOF'; /* @@ -24,13 +42,6 @@ DEFINE_LHASH_OF(FUNCTION); EOF -grep(s/\.o//, @ARGV); -grep(s/^asn1pars$/asn1parse/, @ARGV); -grep(s/^crl2p7$/crl2pkcs7/, @ARGV); -push @ARGV, 'list'; -push @ARGV, 'help'; -push @ARGV, 'exit'; - foreach (@ARGV) { printf "extern int %s_main(int argc, char *argv[]);\n", $_; } @@ -43,7 +54,7 @@ foreach (@ARGV) { print "\n#ifdef INCLUDE_FUNCTION_TABLE\n"; print "static FUNCTION functions[] = {\n"; foreach (@ARGV) { - $str=" { FT_general, \"$_\", ${_}_main, ${_}_options },\n"; + my $str=" { FT_general, \"$_\", ${_}_main, ${_}_options },\n"; if (/^s_/ || /^ciphers$/) { print "#if !defined(OPENSSL_NO_SOCK)\n${str}#endif\n"; } elsif (/^engine$/) { @@ -101,7 +112,7 @@ foreach ( "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb", "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb" ) { - $str=" { FT_cipher, \"$_\", enc_main, enc_options },\n"; + my $str=" { FT_cipher, \"$_\", enc_main, enc_options },\n"; if (/des/) { printf "#ifndef OPENSSL_NO_DES\n${str}#endif\n"; } elsif (/aes/) { |