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>
This commit is contained in:
		@@ -50,7 +50,7 @@ SRC	= \
 | 
			
		||||
	genpkey.c genrsa.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c pkcs8.c \
 | 
			
		||||
	pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c rsautl.c \
 | 
			
		||||
	s_client.c s_server.c s_time.c sess_id.c smime.c speed.c spkac.c \
 | 
			
		||||
	srp.c ts.c verify.c version.c x509.c
 | 
			
		||||
	srp.c ts.c verify.c version.c x509.c rehash.c
 | 
			
		||||
 | 
			
		||||
EXE_OBJ	= openssl.o $(OBJ) $(EXTRA_OBJ) $(RAND_OBJ)
 | 
			
		||||
EXE_SRC = openssl.c $(SRC) $(EXTRA_SRC) $(RAND_SRC)
 | 
			
		||||
@@ -108,7 +108,7 @@ uninstall:
 | 
			
		||||
	done
 | 
			
		||||
	$(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
 | 
			
		||||
 | 
			
		||||
generate: openssl-vms.cnf
 | 
			
		||||
generate: openssl-vms.cnf progs.h
 | 
			
		||||
 | 
			
		||||
depend:
 | 
			
		||||
	$(TOP)/util/domd $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(EXE_SRC)
 | 
			
		||||
@@ -123,7 +123,7 @@ $(DLIBSSL):
 | 
			
		||||
$(DLIBCRYPTO):
 | 
			
		||||
	(cd ..; $(MAKE) build_libcrypto)
 | 
			
		||||
 | 
			
		||||
$(EXE): progs.h $(EXE_OBJ) $(DLIBCRYPTO) $(DLIBSSL)
 | 
			
		||||
$(EXE): $(EXE_OBJ) $(DLIBCRYPTO) $(DLIBSSL)
 | 
			
		||||
	$(RM) $(EXE)
 | 
			
		||||
	shlib_target=; if [ -n "$(SHARED_LIBS)" ]; then \
 | 
			
		||||
		shlib_target="$(SHLIB_TARGET)"; \
 | 
			
		||||
@@ -135,10 +135,9 @@ $(EXE): progs.h $(EXE_OBJ) $(DLIBCRYPTO) $(DLIBSSL)
 | 
			
		||||
		LIBDEPS="$(PLIB_LDFLAG) $$LIBRARIES $(EX_LIBS)" \
 | 
			
		||||
		link_app.$${shlib_target}
 | 
			
		||||
 | 
			
		||||
progs.h: progs.pl Makefile
 | 
			
		||||
progs.h: progs.pl Makefile.in
 | 
			
		||||
	$(RM) progs.h
 | 
			
		||||
	$(PERL) progs.pl $(COMMANDS) >progs.h
 | 
			
		||||
	$(RM) openssl.o
 | 
			
		||||
	$(PERL) progs.pl $(EXE_SRC) > progs.h
 | 
			
		||||
 | 
			
		||||
CA.pl: CA.pl.in
 | 
			
		||||
	$(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl -oapps/Makefile CA.pl.in > CA.pl.new
 | 
			
		||||
 
 | 
			
		||||
@@ -16,9 +16,3 @@ DEPEND[openssl]=../libssl
 | 
			
		||||
 | 
			
		||||
SCRIPTS=CA.pl
 | 
			
		||||
SOURCE[CA.pl]=CA.pl.in
 | 
			
		||||
 | 
			
		||||
BEGINRAW[Makefile]
 | 
			
		||||
{- $builddir -}/progs.h: {- $sourcedir -}/progs.pl {- $builddir -}/../Makefile
 | 
			
		||||
	$(RM) {- $builddir -}/progs.h
 | 
			
		||||
	$(PERL) {- $sourcedir -}/progs.pl $(COMMANDS) >{- $builddir -}/progs.h
 | 
			
		||||
ENDRAW[Makefile]
 | 
			
		||||
 
 | 
			
		||||
@@ -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/) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user