Make generation of dependency files more efficient when possible
authorRichard Levitte <levitte@openssl.org>
Sat, 27 Feb 2016 23:20:50 +0000 (00:20 +0100)
committerRichard Levitte <levitte@openssl.org>
Sun, 28 Feb 2016 00:16:44 +0000 (01:16 +0100)
When building with GNU C, clang or VMS C, it's more efficient to
generate dependency file and object file in one call rather than two.
Have the dependency output in a temporary file and compare it with the
previous one if available to see if replacement is waranted, thereby
avoiding unnecessary reconstruction of Makefile / descrip.mms.

Github issue #750

Reviewed-by: Rich Salz <rsalz@openssl.org>
Configurations/descrip.mms.tmpl
Configurations/unix-Makefile.tmpl

index eb60b4ad814ce0b037749cdf8fd97e02bf1ae2b5..b7e047ba7c4d4cd1f020542e9c6a128144b702b3 100644 (file)
@@ -435,19 +435,15 @@ configdata.pm : {- sourcefile("Configurations", "descrip.mms.tmpl") -} $(SRCDIR)
       my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
 
       return <<"EOF";
-$obj.MMS : $deps
+$obj.OBJ : $deps
         ${before}
         SET DEFAULT $forward
-        \$(CC) \$(CFLAGS)${incs} /MMS=(FILE=${objd}${objn}.MMS,TARGET=$obj.OBJ) /NOOBJECT $srcs
-        SET DEFAULT $backward
-        ${after}
-        - PURGE $obj.MMS
-$obj.OBJ : $obj.MMS
-        ${before}
-        SET DEFAULT $forward
-        \$(CC) \$(CFLAGS)${incs} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
+        \$(CC) \$(CFLAGS)${incs} /MMS=(FILE=${objd}${objn}.tmp-MMS,TARGET=$obj.OBJ) /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
         SET DEFAULT $backward
         ${after}
+        \@ PIPE ( \$(PERL) -e "use File::Compare qw/compare_text/; my \$x = compare_text(""$obj.MMS"",""$obj.tmp-MMS""); exit(0x10000000 + (\$x == 0));" || -
+                 RENAME $obj.tmp-MMS $obj.mms )
+        \@ IF F\$SEARCH("$obj.tmp-MMS") .NES. "" THEN DELETE $obj.tmp-MMS;*
         - PURGE $obj.OBJ
 EOF
   }
index b9fc5f87e7ea645b2787a702f2496d6f01f200e4..cff0023a3e310416a23508cf277076c0bca1f26c 100644 (file)
@@ -847,11 +847,12 @@ $obj$objext: $obj$depext
 EOF
       }
       return <<"EOF";
-$obj$depext: $deps
-       \$(CC) \$(CFLAGS) $ecflags$incs -MM -MF \$\@ -MQ $obj$objext $srcs
-       touch \$\@
-$obj$objext: $obj$depext
-       \$(CC) \$(CFLAGS) $ecflags$incs -c -o \$\@ $srcs
+$obj$objext: $deps
+       \$(CC) \$(CFLAGS) $ecflags$incs -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
+       \@touch $obj$depext.tmp
+       \@if ! cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
+               mv $obj$depext.tmp $obj$depext; \\
+       fi
 EOF
   }
   # On Unix, we build shlibs from static libs, so we're ignoring the