[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-ng] [PATCH 2/4] [ng] deptrack: refactoring for "fastdep" mode
From: |
Stefano Lattarini |
Subject: |
[Automake-ng] [PATCH 2/4] [ng] deptrack: refactoring for "fastdep" mode |
Date: |
Thu, 26 Jan 2012 14:44:21 +0100 |
* lib/am/depcomp2.am: Use more GNU make capabilities in the rules
implementing fast dependency tracking. This change nicely reduce
the size and complexity of the existing code.
* automake.in (handle_languages): Simplify accordingly.
---
automake.in | 30 ------------------------------
lib/am/depend2.am | 46 ++++++++++++++++++++++++----------------------
2 files changed, 24 insertions(+), 52 deletions(-)
diff --git a/automake.in b/automake.in
index 521d6cf..637efca 100644
--- a/automake.in
+++ b/automake.in
@@ -1385,27 +1385,6 @@ sub handle_languages
# This is not used by depend2.am.
my $der_ext = (&{$lang->output_extensions} ($ext))[0];
- # When we output an inference rule like `.c.o:' we
- # have two cases to consider: either subdir-objects
- # is used, or it is not.
- #
- # In the latter case the rule is used to build objects
- # in the current directory, and dependencies always
- # go into `./$(DEPDIR)/'. We can hard-code this value.
- #
- # In the former case the rule can be used to build
- # objects in sub-directories too. Dependencies should
- # go into the appropriate sub-directories, e.g.,
- # `sub/$(DEPDIR)/'. The value of this directory
- # needs to be computed on-the-fly.
- #
- # DEPBASE holds the name of this directory, plus the
- # basename part of the object file (extensions Po, TPo,
- # Plo, TPlo will be added later as appropriate). It is
- # either hardcoded, or a shell variable (`$depbase') that
- # will be computed by the rule.
- my $depbase =
- option ('subdir-objects') ? '$$depbase' : '$(DEPDIR)/$*';
$output_rules .=
file_contents ($rule_file,
new Automake::Location,
@@ -1414,7 +1393,6 @@ sub handle_languages
'DERIVED-EXT' => $der_ext,
- DEPBASE => $depbase,
BASE => '$*',
SOURCE => '$<',
SOURCEFLAG => $sourceflags{$ext} || '',
@@ -1472,20 +1450,12 @@ sub handle_languages
# We _need_ `-o' for per object rules.
my $output_flag = $lang->output_flag || '-o';
- my $depbase = dirname ($obj);
- $depbase = ''
- if $depbase eq '.';
- $depbase .= '/'
- unless $depbase eq '';
- $depbase .= '$(DEPDIR)/' . basename ($obj);
-
$output_rules .=
file_contents ($rule_file,
new Automake::Location,
%transform,
GENERIC => 0,
- DEPBASE => $depbase,
BASE => $obj,
SOURCE => $source,
SOURCEFLAG => $sourceflags{$srcext} || '',
diff --git a/lib/am/depend2.am b/lib/am/depend2.am
index 9a193a4..b948a2a 100644
--- a/lib/am/depend2.am
+++ b/lib/am/depend2.am
@@ -1,6 +1,7 @@
## automake - create Makefile.in from Makefile.am
## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-## 2003, 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+## 2003, 2004, 2006, 2008, 2009, 2010, 2012 Free Software Foundation,
+## Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -57,19 +58,23 @@
## line and is therefore easier to spot. (We need an extra line when
## depbase is used.)
+if %?FIRST%
+?SUBDIROBJ?am__depdir = $(dir $@)/$(DEPDIR)
+?!SUBDIROBJ?am__depdir = $(DEPDIR)
+## FIXME: more precise in the removal of the suffix?
+am__depbase = $(am__depdir)/$(basename $(notdir $@))
+endif %?FIRST%
+
if %?NONLIBTOOL%
?GENERIC?%EXT%.o:
?!GENERIC?%OBJ%: %SOURCE%
if %FASTDEP%
## In fast-dep mode, we can always use -o.
+ %VERBOSE%%COMPILE% -MT $@ -MD -MP -MF $(am__depbase).Tpo %-c% -o $@ \
+?GENERIC? %SOURCEFLAG%%SOURCE%
## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC? %VERBOSE%%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o
%OBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
-?!GENERIC? %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??!SUBDIROBJ? %VERBOSE%%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo
%-c% -o %OBJ% %SOURCEFLAG%%SOURCE%
-?GENERIC??!SUBDIROBJ? %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??SUBDIROBJ? %VERBOSE%depbase=`echo %OBJ% | sed
's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
-?GENERIC??SUBDIROBJ? %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o
%OBJ% %SOURCEFLAG%%SOURCE% &&\
-?GENERIC??SUBDIROBJ? $(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
+?!GENERIC? %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
+ %SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Po
else !%FASTDEP%
if %AMDEP%
%VERBOSE%source='%SOURCE%' object='%OBJ%' libtool=no @AMDEPBACKSLASH@
@@ -89,14 +94,14 @@ endif !%FASTDEP%
?!GENERIC?%OBJOBJ%: %SOURCE%
if %FASTDEP%
## In fast-dep mode, we can always use -o.
+ %VERBOSE%%COMPILE% -MT $@ -MD -MP -MF $(am__depbase).Tpo %-c% -o $@ \
+?GENERIC? %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'`
## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC? %VERBOSE%%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? %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??!SUBDIROBJ? %VERBOSE%%COMPILE% -MT %OBJOBJ% -MD -MP -MF
%DEPBASE%.Tpo %-c% -o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'`
-?GENERIC??!SUBDIROBJ? %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??SUBDIROBJ? %VERBOSE%depbase=`echo %OBJ% | sed
's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
-?GENERIC??SUBDIROBJ? %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c%
-o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'` &&\
-?GENERIC??SUBDIROBJ? $(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
+?!GENERIC? %SOURCEFLAG%`if test -f '%SOURCE%'; \
+?!GENERIC? then $(CYGPATH_W) '%SOURCE%'; \
+?!GENERIC? else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; \
+?!GENERIC? fi`
+ %SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Po
else !%FASTDEP%
if %AMDEP%
%VERBOSE%source='%SOURCE%' object='%OBJOBJ%' libtool=no @AMDEPBACKSLASH@
@@ -118,14 +123,11 @@ if %?LIBTOOL%
?!GENERIC?%LTOBJ%: %SOURCE%
if %FASTDEP%
## In fast-dep mode, we can always use -o.
+ %VERBOSE%%LTCOMPILE% -MT $@ -MD -MP -MF $(am__depbase).Tpo %-c% -o $@ \
+?GENERIC? %SOURCEFLAG%%SOURCE%
## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC? %VERBOSE%%LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c%
-o %LTOBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
-?!GENERIC? %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Plo
-?GENERIC??!SUBDIROBJ? %VERBOSE%%LTCOMPILE% -MT %LTOBJ% -MD -MP -MF
%DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCEFLAG%%SOURCE%
-?GENERIC??!SUBDIROBJ? %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Plo
-?GENERIC??SUBDIROBJ? %VERBOSE%depbase=`echo %OBJ% | sed
's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
-?GENERIC??SUBDIROBJ? %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c%
-o %LTOBJ% %SOURCEFLAG%%SOURCE% &&\
-?GENERIC??SUBDIROBJ? $(am__mv) %DEPBASE%.Tpo %DEPBASE%.Plo
+?!GENERIC? %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
+ %SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Plo
else !%FASTDEP%
if %AMDEP%
%VERBOSE%source='%SOURCE%' object='%LTOBJ%' libtool=yes @AMDEPBACKSLASH@
--
1.7.7.3