From f4a748a17d6a38f410acd342e8539d0e7196cbdb Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 10 Feb 2016 19:11:40 +0100 Subject: Produce buildinf.h on Windows the same way as on Unix Because ENGINESDIR and OPENSSLDIR typically contains backslashes, they need to be escaped just right. Reviewed-by: Rich Salz --- util/check-buildinfo.pl | 43 +++++++++++++++++++++++++++++++++++++++ util/mk1mf.pl | 53 +++++++++++++++++-------------------------------- util/mkbuildinf.pl | 26 +++++++++++------------- 3 files changed, 73 insertions(+), 49 deletions(-) create mode 100644 util/check-buildinfo.pl (limited to 'util') diff --git a/util/check-buildinfo.pl b/util/check-buildinfo.pl new file mode 100644 index 0000000000..176b956900 --- /dev/null +++ b/util/check-buildinfo.pl @@ -0,0 +1,43 @@ +#! /usr/bin/perl + +my %MINFO_source = (); + +open my $minfo, "MINFO" or die "Couldn't open MINFO: $!\n"; +my $reldir = ""; +my $searchterm = ""; +my $goal = ""; +while (<$minfo>) { + chomp; + + if (/^RELATIVE_DIRECTORY=(.*)$/) { + $reldir=$1; + next; + } + + if (/^LIBSRC=(.*)$/) { + my @src = sort split(/\s+/, $1); + if ($reldir =~ m|^crypto(/.*)?$|) { + $MINFO_source{"libcrypto|$reldir"} = [ @src ]; + } elsif ($reldir eq "ssl") { + $MINFO_source{"libssl|$reldir"} = [ @src ]; + } elsif ($reldir ne "engines") { + warn "LIBSRC found in MINFO for $reldir"; + } + next; + } + + if (/^(?:TEST)?LIBNAMES=(.*)$/) { + my @names = sort split(/\s+/, $1); + if ($reldir eq "engines") { + push @{$MINFO_source{"engines|$reldir"}}, @names; + } else { + warn "(TEST)?LIBNAMES found in MINFO for $reldir"; + } + next; + } + + } elsif ($reldir eq "apps") { + $searchterm = "EXE_SRC"; + $goal = "apps|openssl"; + } elsif ($reldir eq "engines") { + $searchterm = " diff --git a/util/mk1mf.pl b/util/mk1mf.pl index e79733d710..07968c4148 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -52,6 +52,7 @@ my %mf_import = ( PLATFORM => \$mf_platform, CC => \$mf_cc, CFLAG => \$mf_cflag, + CFLAG_Q => \$mf_cflag_q, DEPFLAG => \$mf_depflag, CPUID_OBJ => \$mf_cpuid_asm, BN_ASM => \$mf_bn_asm, @@ -616,6 +617,15 @@ EOF my $asm_def = $orig_platform eq 'copy' ? "" : "ASM=$bin_dir$asm"; +$cflags =~ s/\((ENGINESDIR|OPENSSLDIR)\)/\(${1}_QQ\)/g; +(my $cflags_q = $cflags) =~ s/([\\"])/\\$1/g; +(my $INSTALLTOP_Q = $INSTALLTOP) =~ s/([\\"])/\\$1/g; +(my $INSTALLTOP_QQ = $INSTALLTOP_Q) =~ s/\\/\\\\/g; +(my $OPENSSLDIR_Q = $OPENSSLDIR) =~ s/([\\"])/\\$1/g; +(my $OPENSSLDIR_QQ = $OPENSSLDIR_Q) =~ s/\\/\\\\/g; +(my $ENGINESDIR_Q = $ENGINESDIR) =~ s/([\\"])/\\$1/g; +(my $ENGINESDIR_QQ = $ENGINESDIR_Q) =~ s/\\/\\\\/g; + $defs= <<"EOF"; # N.B. You MUST use -j on FreeBSD. # This makefile has been automatically generated from the OpenSSL distribution. @@ -637,13 +647,17 @@ $defs .= $preamble if defined $preamble; $defs.= <<"EOF"; INSTALLTOP=$INSTALLTOP +INSTALLTOP_QQ=$INSTALLTOP_QQ OPENSSLDIR=$OPENSSLDIR +OPENSSLDIR_QQ=$OPENSSLDIR_QQ ENGINESDIR=$ENGINESDIR +ENGINESDIR_QQ=$ENGINESDIR_QQ # Set your compiler options PLATFORM=$platform CC=$bin_dir${cc} CFLAG=$cflags +CFLAG_Q=$cflags_q APP_CFLAG=$app_cflag LIB_CFLAG=$lib_cflag SHLIB_CFLAG=$shl_cflag @@ -794,41 +808,11 @@ EOF $rules .= &do_rehash_rule("rehash.time", "certs/demo apps tools"); $rules .= &do_test_rule("test", "rehash.time", "run_tests.pl"); -my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; -$platform_cpp_symbol =~ s/-/_/g; -if (open(IN,"crypto/buildinf.h")) - { - # Remove entry for this platform in existing file buildinf.h. - - my $old_buildinf_h = ""; - while () - { - if (/^\#ifdef $platform_cpp_symbol$/) - { - while () { last if (/^\#endif/); } - } - else - { - $old_buildinf_h .= $_; - } - } - close(IN); - - open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; - print OUT $old_buildinf_h; - close(OUT); - } - -open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; -printf OUT <<"EOF"; -#ifdef $platform_cpp_symbol - /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ - #define CFLAGS "compiler: $cc $cflags" - #define PLATFORM "$platform" +$rules .= <<"EOF"; +crypto${o}buildinf.h : MINFO + \$(PERL) util${o}mkbuildinf.pl "\$(CC) \$(CFLAG_Q)" "\$(PLATFORM)" > crypto${o}buildinf.h +$(OBJ_D)${o}cversion${obj} : crypto${o}buildinf.h EOF -printf OUT " #define DATE \"%s\"\n", scalar gmtime(); -printf OUT "#endif\n"; -close(OUT); # Strip off trailing ' ' foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } @@ -1277,7 +1261,6 @@ sub cc_compile_target local($target,$source,$ex_flags)=@_; local($ret); - $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); $target =~ s/\//$o/g if $o ne "/"; $source =~ s/\//$o/g if $o ne "/"; $ret ="$target: \$(SRC_D)$o$source\n\t"; diff --git a/util/mkbuildinf.pl b/util/mkbuildinf.pl index b880c7f226..9071b7114f 100755 --- a/util/mkbuildinf.pl +++ b/util/mkbuildinf.pl @@ -5,15 +5,14 @@ my ($cflags, $platform) = @ARGV; $cflags = "compiler: $cflags"; $date = localtime(); print <<"END_OUTPUT"; -#ifndef MK1MF_BUILD - /* auto-generated by util/mkbuildinf.pl for crypto/cversion.c */ - #define CFLAGS cflags - /* - * Generate CFLAGS as an array of individual characters. This is a - * workaround for the situation where CFLAGS gets too long for a C90 string - * literal - */ - static const char cflags[] = { +/* auto-generated by util/mkbuildinf.pl for crypto/cversion.c */ +#define CFLAGS cflags +/* + * Generate CFLAGS as an array of individual characters. This is a + * workaround for the situation where CFLAGS gets too long for a C90 string + * literal + */ +static const char cflags[] = { END_OUTPUT my $ctr = 0; foreach my $c (split //, $cflags) { @@ -23,14 +22,13 @@ foreach my $c (split //, $cflags) { if ($ctr != 1) { print "\n"; } - print " "; + print " "; } print "'$c',"; } print <<"END_OUTPUT"; '\\0' - }; - #define PLATFORM "platform: $platform" - #define DATE "built on: $date" -#endif +}; +#define PLATFORM "platform: $platform" +#define DATE "built on: $date" END_OUTPUT -- cgit v1.2.3