X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=util%2Fmk1mf.pl;h=b05c4aeed4e255482b5e26dba17c876526da811f;hp=24ee3120dc66b51b8882cfa70b30e1eebf85fd6c;hb=a50f71868ece56af1be1e37504dc95df7154a90b;hpb=2f297fce734aa1ba38836e1a75f65e0a48bfa0c7 diff --git a/util/mk1mf.pl b/util/mk1mf.pl index 24ee3120dc..b05c4aeed4 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -1,9 +1,13 @@ -#!/usr/local/bin/perl +#!/usr/bin/env perl # A bit of an evil hack but it post processes the file ../MINFO which # is generated by `make files` in the top directory. # This script outputs one mega makefile that has no shell stuff or any -# funny stuff -# +# funny stuff (if the target is not "copy"). +# If the target is "copy", then it tries to create a makefile that can be +# safely used with the -j flag and that is compatible with the top-level +# Makefile, in the sense that it uses the same options and assembler files etc. + +use Cwd; $INSTALLTOP="/usr/local/ssl"; $OPENSSLDIR="/usr/local/ssl"; @@ -188,7 +192,7 @@ $mkdir="-mkdir" unless defined $mkdir; $ranlib="echo ranlib"; $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; -$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; +$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}: $platform eq 'copy' ? getcwd() : '.'; $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; # $bin_dir.=$o causes a core dump on my sparc :-( @@ -451,6 +455,14 @@ for (;;) } close(IN); +if ($orig_platform eq 'copy') + { + # Remove opensslconf.h so it doesn't get updated if we configure a + # different branch. + $exheader =~ s/[^ ]+\/opensslconf.h//; + $header =~ s/[^ ]+\/opensslconf.h//; + } + if ($fips) { @@ -606,6 +618,7 @@ EOF } $defs= <<"EOF"; +# N.B. You MUST use -j on FreeBSD. # This makefile has been automatically generated from the OpenSSL distribution. # This single makefile will build the complete OpenSSL distribution and # by default leave the 'intertesting' output files in .${o}out and the stuff @@ -664,7 +677,7 @@ RANLIB=$ranlib MKDIR=$mkdir MKLIB=$bin_dir$mklib MLFLAGS=$mlflags -ASM=$bin_dir$asm +#ASM=$bin_dir$asm # FIPS validated module and support file locations @@ -748,6 +761,11 @@ $banner \$(INC_D): \$(MKDIR) \"\$(INC_D)\" +# This needs to be invoked once, when the makefile is first constructed, or +# after cleaning. +init: \$(TMP_D) \$(LIB_D) \$(INC_D) \$(INCO_D) \$(BIN_D) \$(TEST_D) headers + \$(PERL) \$(SRC_D)/util/copy-if-different.pl "\$(SRC_D)/crypto/opensslconf.h" "\$(INCO_D)/opensslconf.h" + headers: \$(HEADER) \$(EXHEADER) lib: \$(LIBS_DEP) \$(E_SHLIB) @@ -762,11 +780,6 @@ install: all \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" $extra_install - -test: \$(T_EXE) - cd \$(BIN_D) - ..${o}ms${o}test - clean: \$(RM) \$(TMP_D)$o*.* @@ -782,7 +795,17 @@ reallyclean: \$(RM) -rf \$(INC_D) EOF - + +if ($orig_platform ne 'copy') + { + $rules .= <<"EOF"; +test: \$(T_EXE) + cd \$(BIN_D) + ..${o}ms${o}test + +EOF + } + my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; $platform_cpp_symbol =~ s/-/_/g; if (open(IN,"crypto/buildinf.h")) @@ -875,16 +898,18 @@ sub fix_asm return $asm . ' '; } -$lib_obj{CRYPTO} .= fix_asm($mf_md5_asm, 'crypto/md5'); -$lib_obj{CRYPTO} .= fix_asm($mf_bn_asm, 'crypto/bn'); -# cpuid is included by the crypto dir -#$lib_obj{CRYPTO} .= fix_asm($mf_cpuid_asm, 'crypto'); -# AES asm files end up included by the aes dir itself -#$lib_obj{CRYPTO} .= fix_asm($mf_aes_asm, 'crypto/aes'); -$lib_obj{CRYPTO} .= fix_asm($mf_sha_asm, 'crypto/sha'); -$lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines'); -$lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4'); -$lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes'); +if ($orig_platform eq 'copy') { + $lib_obj{CRYPTO} .= fix_asm($mf_md5_asm, 'crypto/md5'); + $lib_obj{CRYPTO} .= fix_asm($mf_bn_asm, 'crypto/bn'); + # cpuid is included by the crypto dir + #$lib_obj{CRYPTO} .= fix_asm($mf_cpuid_asm, 'crypto'); + # AES asm files end up included by the aes dir itself + #$lib_obj{CRYPTO} .= fix_asm($mf_aes_asm, 'crypto/aes'); + $lib_obj{CRYPTO} .= fix_asm($mf_sha_asm, 'crypto/sha'); + $lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines'); + $lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4'); + $lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes'); +} foreach (values %lib_nam) { @@ -1012,6 +1037,8 @@ if ($fips) $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0); +$rules .= get_tests('test/Makefile') if $orig_platform eq 'copy'; + print $defs; if ($platform eq "linux-elf") { @@ -1251,15 +1278,15 @@ sub perlasm_compile_target my($ret); $bname =~ s/(.*)\.[^\.]$/$1/; - $ret ="\$(TMP_D)$o$bname.asm: $source\n"; + $ret ="\$(TMP_D)$o$bname$asm_suffix: $source\n"; $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n"; if ($fipscanisteronly) { - $ret .= "\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n"; + $ret .= "\t\$(PERL) util$o.pl . \$@ norunasm \$(CFLAG)\n"; } $ret .= "\n"; - $ret.="$target: \$(TMP_D)$o$bname.asm\n"; - $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; + $ret.="$target: \$(TMP_D)$o$bname$asm_suffix\n"; + $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname$asm_suffix\n\n"; return($ret); } @@ -1286,9 +1313,12 @@ sub cc_compile_target $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 "/"; -# FIXME: do dependencies instead of all headers. - $ret ="$target: \$(SRC_D)$o$source \$(HEADER) \$(EXHEADER)\n\t"; - $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; + $ret ="$target: \$(SRC_D)$o$source\n\t"; + $ret.="\$(CC)"; + $ret.= " -MMD" if $orig_platform eq "copy"; + $ret.= " ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; + $target =~ s/\.o$/.d/; + $ret.=".sinclude \"$target\"\n\n" if $orig_platform eq "copy"; return($ret); } @@ -1353,7 +1383,7 @@ sub do_copy_rule if ($n =~ /bss_file/) { $pp=".c"; } else { $pp=$p; } - $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp $to\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n"; + $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(PERL) \$(SRC_D)${o}util${o}copy-if-different.pl \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n"; } return($ret); }