From f899ad275df34081b63540cda9657d30aa80bd73 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Wed, 17 Jan 2007 17:12:17 +0000 Subject: [PATCH] Initial support for new build options under WIN32 and VC++. --- util/copy.pl | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ util/mk1mf.pl | 56 ++++++++++++++++++++++++++------------ util/pl/VC-32.pl | 14 ++++++---- 3 files changed, 119 insertions(+), 22 deletions(-) create mode 100644 util/copy.pl diff --git a/util/copy.pl b/util/copy.pl new file mode 100644 index 0000000000..5f00f95186 --- /dev/null +++ b/util/copy.pl @@ -0,0 +1,71 @@ +#!/usr/local/bin/perl + +use Fcntl; + + +# copy.pl + +# Perl script 'copy' comment. On Windows the built in "copy" command also +# copies timestamps: this messes up Makefile dependencies. +# + +my $stripcr = 0; + +my $arg; + +foreach $arg (@ARGV) { + if ($arg eq "-stripcr") + { + $stripcr = 1; + next; + } + $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... + foreach (glob $arg) + { + push @filelist, $_; + } +} + +$fnum = @filelist; + +if ($fnum <= 1) + { + die "Need at least two filenames"; + } + +$dest = pop @filelist; + +if ($fnum > 2 && ! -d $dest) + { + die "Destination must be a directory"; + } + +foreach (@filelist) + { + if (-d $dest) + { + $dfile = $_; + $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|; + $dfile = "$dest/$dfile"; + } + else + { + $dfile = $dest; + } + sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_"; + sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY) + || die "Can't Open $dfile"; + while (sysread IN, $buf, 10240) + { + if ($stripcr) + { + $buf =~ tr/\015//d; + } + syswrite(OUT, $buf, length($buf)); + } + close(IN); + close(OUT); + print "Copying: $_ to $dfile\n"; + } + + diff --git a/util/mk1mf.pl b/util/mk1mf.pl index 05a6086164..e704291855 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -18,6 +18,8 @@ my $fips_premain_dso_exe_path = ""; my $fips_premain_c_path = ""; my $fips_sha1_exe_path = ""; +local $fipscanisterbuild = 0; + my $fipslibdir = ""; my $baseaddr = ""; @@ -315,7 +317,7 @@ for (;;) $uc =~ s/^lib(.*)\.a/$1/; $uc =~ tr/a-z/A-Z/; } - if (($uc ne "FIPS") || $fips_canister_build) + if (($uc ne "FIPS") || $fipscanisterbuild) { $lib_nam{$uc}=$uc; $lib_obj{$uc}.=$libobj." "; @@ -371,14 +373,22 @@ for (;;) } close(IN); -if ($fips_canister_path eq "") +if ($fipscanisterbuild) { - $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.o"; + $fips_canister_path = "\$(LIB_D)${o}fipscanister.o"; + $fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c"; } - -if ($fips_premain_c_path eq "") +else { - $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c"; + if ($fips_canister_path eq "") + { + $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.o"; + } + + if ($fips_premain_c_path eq "") + { + $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c"; + } } if ($fips) @@ -408,16 +418,23 @@ if ($fips) $ex_build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)"; $ex_l_libs .= " \$(O_FIPSCANISTER)"; } - if ($fipslibdir eq "") + if ($fipscanisterbuild) { - open (IN, "util/fipslib_path.txt") || fipslib_error(); - $fipslibdir = ; - chomp $fipslibdir; - close IN; + $fipslibdir = "\$(LIB_D)"; + } + else + { + if ($fipslibdir eq "") + { + open (IN, "util/fipslib_path.txt") || fipslib_error(); + $fipslibdir = ; + chomp $fipslibdir; + close IN; + } + fips_check_files($fipslibdir, + "fipscanister.o", "fipscanister.o.sha1", + "fips_premain.c", "fips_premain.c.sha1"); } - fips_check_files($fipslibdir, - "fipscanister.o", "fipscanister.o.sha1", - "fips_premain.c", "fips_premain.c.sha1"); } @@ -684,7 +701,7 @@ $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); if ($fips) { - if ($fips_canister_build) + if ($fipscanisterbuild) { $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj", "fips-1.0${o}fips_canister.c", @@ -697,7 +714,7 @@ if ($fips) "\$(SHLIB_CFLAGS)"); $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_sha1dgst$obj", "fips-1.0${o}sha${o}fips_sha1dgst.c", - "\$(SHLIB_CFLAGS)") unless $fips_canister_build; + "\$(SHLIB_CFLAGS)") unless $fipscanisterbuild; $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj", "fips-1.0${o}fips_premain.c", "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)"); @@ -807,7 +824,7 @@ if ($fips) if ($fips) { - $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)", "\$(OBJ_D)${o}fips_start$obj \$(FIPSOBJ) \$(OBJ_D)${o}fips_end$obj", "\$(FIPSLIB_D)${o}fips_standalone_sha1$exep", "") if $fips_canister_build; + $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)", "\$(OBJ_D)${o}fips_start$obj \$(FIPSOBJ) \$(OBJ_D)${o}fips_end$obj", "\$(FIPS_SHA1_EXE)", "") if $fipscanisterbuild; $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1); $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)","\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}fips_sha1dgst$obj","","", 1); @@ -1128,6 +1145,11 @@ sub read_options } } } + elsif (/^--fipscanisterbuild$/) + { + print STDERR "FIPS CANISTER BUILD\n"; + $fipscanisterbuild=1; + } elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } elsif (/^-[lL].*$/) { $l_flags.="$_ "; } elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl index 4e97dfa9af..1ba2f84656 100644 --- a/util/pl/VC-32.pl +++ b/util/pl/VC-32.pl @@ -77,6 +77,7 @@ $des_enc_src=''; $bf_enc_obj=''; $bf_enc_src=''; + if (!$no_asm && !$fips) { $bn_asm_obj='crypto\bn\asm\bn_win32.obj'; @@ -135,7 +136,7 @@ sub do_lib_rule # $ret.="\t\$(RM) \$(O_$Name)\n"; $ret.="$target: $objs\n"; $ex =' advapi32.lib'; - $ex.=" \$(FIPSLIB_D)${o}_chkstk.o" if $fips && $target =~ /O_CRYPTO/; + $ex.=" \$(FIPSLIB_D)${o}_chkstk.o" if $fips && !$fipscanisterbuild && $target =~ /O_CRYPTO/; $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n"; } else @@ -145,7 +146,7 @@ sub do_lib_rule $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/; if ($fips && $target =~ /O_CRYPTO/) { - $ex.=" \$(FIPSLIB_D)${o}_chkstk.o"; + $ex.=" \$(FIPSLIB_D)${o}_chkstk.o" unless $fipscanisterbuild; $ret.="$target: $objs \$(PREMAIN_DSO_EXE)\n"; $ret.="\tSET FIPS_LINK=\$(LINK)\n"; $ret.="\tSET FIPS_CC=\$(CC)\n"; @@ -178,7 +179,7 @@ sub do_link_rule if ($standalone) { $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t"; - $ret.="\$(FIPSLIB_D)${o}_chkstk.o " if ($files =~ /O_FIPSCANISTER/); + $ret.="\$(FIPSLIB_D)${o}_chkstk.o " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild); $ret.="$files $libs\n<<\n"; } elsif ($fips && !$shlib) @@ -209,9 +210,12 @@ sub do_rlink_rule $file =~ s/\//$o/g if $o ne '/'; $n=&bname($targer); - $ret.="$target: $files $dep_libs\n"; - $ret.=" \$(MKCANISTER) $target <<\n"; + $ret.="$target: $files $dep_libs \$(FIPS_SHA1_EXE)\n"; + $ret.="\t\$(MKCANISTER) $target <<\n"; $ret.="INPUT($files)\n<<\n"; + $ret.="\t\$(FIPS_SHA1_EXE) $target > ${target}.sha1\n"; + $ret.="\tperl util${o}copy.pl -stripcr fips-1.0${o}fips_premain.c \$(LIB_D)${o}fips_premain.c\n"; + $ret.="\t\$(CP) fips-1.0${o}fips_premain.c.sha1 \$(LIB_D)${o}fips_premain.c.sha1\n"; $ret.="\n"; return($ret); } -- 2.25.1