From: Stefano Lattarini Date: Thu, 10 Jan 2013 17:04:33 +0000 (+0100) Subject: depend: refactor and remove code duplication X-Git-Tag: v1.16~89^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=v1.13.1d-220-g1fa0c24;p=thirdparty%2Fautomake.git depend: refactor and remove code duplication * lib/am/depend2.am: Here. The obsolescent comments removed from this same file in commit 'v1.13.1-42-g8f06bfb' of 2012-01-09, "depend2.am: fix comments on verbosity of compilation rules", gave the rationale for why that code duplication was there in the first place (rationale that, like those comments, has been obsolete by the silent-rules introduction). * bin/automake.in: Given the refactoring in 'depend2.am', there is no longer need to add extra trailing whitespace to the entries of the '%sourceflags' hash (which are used for the '%SOURCEFLAG%' transform when 'depend2.am' is processed. * t/fort2.sh: Adjust to avoid spurious failures. Signed-off-by: Stefano Lattarini --- diff --git a/bin/automake.in b/bin/automake.in index c87acba72..04906b3f3 100644 --- a/bin/automake.in +++ b/bin/automake.in @@ -5060,9 +5060,7 @@ sub scan_autoconf_traces elsif ($macro eq 'AC_FC_SRCEXT') { my $suffix = $args[1]; - # These flags are used as %SOURCEFLAG% in depend2.am, - # where the trailing space is important. - $sourceflags{'.' . $suffix} = '$(FCFLAGS_' . $suffix . ') ' + $sourceflags{'.' . $suffix} = '$(FCFLAGS_' . $suffix . ')' if ($suffix eq 'f90' || $suffix eq 'f95' || $suffix eq 'f03' || $suffix eq 'f08'); } elsif ($macro eq 'AC_INIT') diff --git a/lib/am/depend2.am b/lib/am/depend2.am index 99e993b00..6c6c6843b 100644 --- a/lib/am/depend2.am +++ b/lib/am/depend2.am @@ -36,47 +36,47 @@ if %?NONLIBTOOL% ?GENERIC?%EXT%.o: ?!GENERIC?%OBJ%: %SOURCE% if %FASTDEP% -## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. ## TODO: rewrite this to avoid extra forks once we can assume a POSIX ## TODO: shell. %VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'` \ -?!GENERIC? && %COMPILE% -MT %OBJ% -MD -MP -MF $$depbase.Tpo -c -o %OBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% \ -?GENERIC? && %COMPILE% -MT %OBJ% -MD -MP -MF $$depbase.Tpo -c -o %OBJ% %SOURCEFLAG%%SOURCE% \ - && $(am__mv) $$depbase.Tpo $$depbase.Po + && %COMPILE% -MT %OBJ% -MD -MP -MF $$depbase.Tpo -c -o %OBJ% %SOURCEFLAG% \ +?GENERIC? %SOURCE% \ +## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. +?!GENERIC? `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% \ + && $(am__mv) $$depbase.Tpo $$depbase.Po else !%FASTDEP% if %AMDEP% %VERBOSE%source='%SOURCE%' object='%OBJ%' libtool=no @AMDEPBACKSLASH@ DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@ endif %AMDEP% -if %?GENERIC% - %VERBOSE-NODEP%%COMPILE% -c -o %OBJ% %SOURCEFLAG%%SOURCE% -else !%?GENERIC% + %VERBOSE-NODEP%%COMPILE% -c -o %OBJ% %SOURCEFLAG% \ +?GENERIC? %SOURCE% ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. - %VERBOSE-NODEP%%COMPILE% -c -o %OBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% -endif !%?GENERIC% +?!GENERIC? `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% endif !%FASTDEP% ?GENERIC?%EXT%.obj: ?!GENERIC?%OBJOBJ%: %SOURCE% if %FASTDEP% -## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. ## TODO: rewrite this to avoid extra forks once we can assume a POSIX ## TODO: shell. %VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'` \ -?!GENERIC? && %COMPILE% -MT %OBJOBJ% -MD -MP -MF $$depbase.Tpo -c -o %OBJOBJ% %SOURCEFLAG%`if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` \ -?GENERIC? && %COMPILE% -MT %OBJOBJ% -MD -MP -MF $$depbase.Tpo -c -o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'` \ + && %COMPILE% -MT %OBJOBJ% -MD -MP -MF $$depbase.Tpo -c -o %OBJOBJ% %SOURCEFLAG% \ +?GENERIC? `$(CYGPATH_W) '%SOURCE%'` \ +## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. +?!GENERIC? `if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; \ +?!GENERIC? else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` \ && $(am__mv) $$depbase.Tpo $$depbase.Po else !%FASTDEP% if %AMDEP% %VERBOSE%source='%SOURCE%' object='%OBJOBJ%' libtool=no @AMDEPBACKSLASH@ DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@ endif %AMDEP% -if %?GENERIC% - %VERBOSE-NODEP%%COMPILE% -c -o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'` -else !%?GENERIC% + %VERBOSE-NODEP%%COMPILE% -c -o %OBJOBJ% %SOURCEFLAG% \ +?GENERIC? `$(CYGPATH_W) '%SOURCE%'` ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. - %VERBOSE-NODEP%%COMPILE% -c -o %OBJOBJ% %SOURCEFLAG%`if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` -endif !%?GENERIC% +?!GENERIC? `if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; \ +?!GENERIC? else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` endif !%FASTDEP% endif %?NONLIBTOOL% @@ -84,20 +84,22 @@ if %?LIBTOOL% ?GENERIC?%EXT%.lo: ?!GENERIC?%LTOBJ%: %SOURCE% if %FASTDEP% -## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. ## TODO: rewrite this to avoid extra forks once we can assume a POSIX ## TODO: shell. %VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'` \ -?!GENERIC? && %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF $$depbase.Tpo -c -o %LTOBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% \ -?GENERIC? && %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF $$depbase.Tpo -c -o %LTOBJ% %SOURCEFLAG%%SOURCE% \ + && %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF $$depbase.Tpo -c -o %LTOBJ% %SOURCEFLAG% \ +?GENERIC? %SOURCE% \ +## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. +?!GENERIC? `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% \ && $(am__mv) $$depbase.Tpo $$depbase.Plo else !%FASTDEP% if %AMDEP% %VERBOSE%source='%SOURCE%' object='%LTOBJ%' libtool=yes @AMDEPBACKSLASH@ DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@ endif %AMDEP% -?GENERIC? %VERBOSE-NODEP%%LTCOMPILE% -c -o %LTOBJ% %SOURCEFLAG%%SOURCE% + %VERBOSE-NODEP%%LTCOMPILE% -c -o %LTOBJ% %SOURCEFLAG% \ +?GENERIC? %SOURCE% ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. -?!GENERIC? %VERBOSE-NODEP%%LTCOMPILE% -c -o %LTOBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% +?!GENERIC? `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% endif !%FASTDEP% endif %?LIBTOOL% diff --git a/t/fort2.sh b/t/fort2.sh index d61445296..bed032368 100755 --- a/t/fort2.sh +++ b/t/fort2.sh @@ -70,8 +70,17 @@ $MAKE -n \ FCFLAGS_f90=--@90 FCFLAGS_f95=--@95 FCFLAGS_f03=--@03 FCFLAGS_f08=--@08 \ > stdout || { cat stdout; exit 1; } cat stdout -# To make it easier to have stricter grepping below. -sed -e 's/[ ][ ]*/ /g' -e 's/^/ /' -e 's/$/ /' stdout > out +# To make it easier to have stricter grepping below. +$PERL -e ' + undef $/; + $_ = <>; + s/[^\\]\\\n/ /g; + s/^/ /; + s/\n/ \n /g; + s/[ \t]+/ /g; + s/\n\s*\z/\n/; + print; +' out cat out grep ' fake-fc .* --@90 .* hello\.f90 ' out