diff --git a/mozilla/config/mddepend.pl b/mozilla/config/mddepend.pl index 440ba5a6072..587497041eb 100644 --- a/mozilla/config/mddepend.pl +++ b/mozilla/config/mddepend.pl @@ -26,6 +26,8 @@ # # Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com). +$outfile = shift @ARGV; + @alldeps=(); # Parse dependency files while ($line = <>) { @@ -69,10 +71,27 @@ foreach $deps (@alldeps) { $modtimes{$dep_file} = $dep_mtime; } if ($dep_mtime eq '' or $dep_mtime > $mtime) { - print "$obj "; - $haveObjects = 1; + push @objs, $obj; last; } } } -print ": FORCE\n" if $haveObjects; + +# Output objects to rebuild (if needed). +if ($#objs > 0) { + $new_output = "@objs: FORCE\n"; + + # Read in the current dependencies file. + open(OLD, "<$outfile") and $old_output = ; + close(OLD); + + # Only write out the dependencies if they are different. + if ($new_output ne $old_output) { + open(OUT, ">$outfile") and print OUT $new_output; + print "Updating dependencies ($outfile).\n"; + } +} elsif (-s $outfile) { + # Remove the old dependencies because all objects are up to date. + unlink $outfile; + print "Removing old dependencies ($outfile).\n"; +} diff --git a/mozilla/config/rules.mk b/mozilla/config/rules.mk index 8b365f41d53..75e15535871 100644 --- a/mozilla/config/rules.mk +++ b/mozilla/config/rules.mk @@ -1044,19 +1044,17 @@ endif # ! COMPILER_DEPEND # Yet another depend system: -MD ifdef COMPILER_DEPEND ifdef OBJS -MDDEPEND_FILES := $(foreach obj, $(OBJS), \ - $(MDDEPDIR)/$(basename $(notdir $(obj))).pp) -MDDEPEND_FILES := $(wildcard $(MDDEPEND_FILES)) +MDDEPEND_FILES := $(wildcard $(MDDEPDIR)/*.pp) ifdef MDDEPEND_FILES ifdef PERL # The script mddepend.pl checks the dependencies and writes to stdout # one rule to force out-of-date objects. For example, # foo.o boo.o: FORCE # The script has an advantage over including the *.pp files directly -# because it handles missing header files. 'make' would complain that -# there is no way to build missing headers. +# because it handles the case when header files are removed from the build. +# 'make' would complain that there is no way to build missing headers. $(MDDEPDIR)/.all.pp: FORCE - @$(PERL) $(topsrcdir)/config/mddepend.pl $(MDDEPEND_FILES) >$@ + @$(PERL) $(topsrcdir)/config/mddepend.pl $@ $(MDDEPEND_FILES) -include $(MDDEPDIR)/.all.pp else include $(MDDEPEND_FILES)