automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-NG] [PATCH 09/14] [ng] clean: don't remove object files in '.'


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH 09/14] [ng] clean: don't remove object files in '.' unconditionally
Date: Thu, 21 Jun 2012 12:32:40 +0200

Do that only if some source file is actually present in the current
directory (which might not be the case for, say, projects that use
a non-recursive make setup and have all sources in the 'src' and 'lib'
subdirectories).

* lib/am/compile.am (am__mostlyclean_files): Don't append '*.$(OBJEXT)'
unconditionally.
* lib/am/libtool.am (am__mostlyclean_files): Don't append '*.lo'
unconditionally.
* automake.in (handle_single_transform): Update '%compile_clean_files'
also for sources in the current directory.  Some related adjustments.
Remove obsolete comments while we are at it.
(handle_LIBOBJS_or_ALLOCA): Update '%compile_clean_files' to list
all the object files in the directory of the extra sources brought
in.  Adjust comments accordingly.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 automake.in       |   71 ++++++++++++++++++++++-------------------------------
 lib/am/compile.am |    2 +-
 lib/am/libtool.am |    1 -
 3 files changed, 30 insertions(+), 44 deletions(-)

diff --git a/automake.in b/automake.in
index 324553a..dd9cb25 100644
--- a/automake.in
+++ b/automake.in
@@ -1838,43 +1838,34 @@ sub handle_single_transform ($$$$$%)
        $linkers_used{$linker} = 1;
 
        push (@result, $object);
+        $directory = '.' if $directory eq '';
 
        if (! defined $object_map{$object})
-       {
+         {
            $object_map{$object} = $full;
 
-           # If resulting object is in subdir, we need to make
-           # sure the subdir exists at build time.
-           if ($object =~ /\//)
-           {
-               # FIXME: check that $DIRECTORY is somewhere in the
-               # project
-
-               # For Java, the way we're handling it right now, a
-               # '..' component doesn't make sense.
-               if ($lang && $lang->name eq 'java' && $object =~ /(\/|^)\.\.\//)
-                 {
-                   err_am "'$full' should not contain a '..' component";
-                 }
-
-                # Make sure *all* objects files in the subdirectory are
-                # removed by "make mostlyclean".  Not only this is more
-                # efficient than listing the object files to be removed
-                # individually (which would cause an 'rm' invocation for
-                # each of them -- very inefficient, see bug#10697), it
-                # would also leave stale object files in the subdirectory
-                # whenever a source file there is removed or renamed.
-                $compile_clean_files{"$directory/*.\$(OBJEXT)"} = MOSTLY_CLEAN;
-                if ($object =~ /\.lo$/)
-                  {
-                    # If we have a libtool object, then we also must remove
-                    # any '.lo' objects in its same subdirectory.
-                    $compile_clean_files{"$directory/*.lo"} = MOSTLY_CLEAN;
-                    # Remember to cleanup .libs/ in this directory.
-                    $libtool_clean_directories{$directory} = 1;
-                  }
-           }
-       }
+            # For Java, the way we're handling it right now, a
+            # '..' component doesn't make sense.
+            err_am "'$full' should not contain a '..' component"
+              if $lang && $lang->name eq 'java' && $object =~ m{(/|^)\.\./};
+
+            # Make sure *all* objects files in this object's subdirectory
+            # are removed by "make mostlyclean".  Not only this is more
+            # efficient than listing the object files to be removed
+            # individually (which would cause an 'rm' invocation for each
+            # of them -- very inefficient, see bug#10697), it would also
+            # leave stale object files in the subdirectory whenever a
+            # source file there is removed or renamed.
+            $compile_clean_files{"$directory/*.\$(OBJEXT)"} = MOSTLY_CLEAN;
+            if ($object =~ /\.lo$/)
+              {
+                # If we have a libtool object, then we also must remove
+                # any '.lo' objects in its same subdirectory.
+                $compile_clean_files{"$directory/*.lo"} = MOSTLY_CLEAN;
+                # Remember to cleanup .libs/ in this directory.
+                $libtool_clean_directories{$directory} = 1;
+              }
+         }
 
        # Transform .o or $o file into .P file (for automatic
        # dependency code).
@@ -2125,11 +2116,8 @@ sub handle_LIBOBJS_or_ALLOCA ($)
   my $dir = '';
 
   # If LIBOBJS files must be built in another directory we have
-  # to define LIBOBJDIR and ensure the files get cleaned.
-  # Otherwise LIBOBJDIR can be left undefined, and the cleaning
-  # is achieved by 'rm -f *.$(OBJEXT)' in compile.am.
-  if ($config_libobj_dir
-      && $relative_dir ne $config_libobj_dir)
+  # to define the 'LIBOBJDIR' make variable.
+  if ($config_libobj_dir && $relative_dir ne $config_libobj_dir)
     {
       # In the top-level Makefile we do not use $(top_builddir), because
       # we are already there, and since the targets are built without
@@ -2138,11 +2126,10 @@ sub handle_LIBOBJS_or_ALLOCA ($)
       $dir = "$config_libobj_dir/" if $config_libobj_dir ne '.';
       $dir = "$topsrcdir/$dir" if $relative_dir ne '.';
       define_variable ('LIBOBJDIR', INTERNAL, $dir);
-      $clean_files{"\$($var)"} = MOSTLY_CLEAN;
-      # If LTLIBOBJS is used, we must also clear LIBOBJS (which might
-      # be created by libtool as a side-effect of creating LTLIBOBJS).
-      $clean_files{"\$($var)"} = MOSTLY_CLEAN if $var =~ s/^LT//;
     }
+  $compile_clean_files{'$(LIBOBJDIR)*.$(OBJEXT)'} = MOSTLY_CLEAN;
+  $compile_clean_files{'$(LIBOBJDIR)*.lo'} = MOSTLY_CLEAN
+    if $var =~ /^LT/;
 
   return $dir;
 }
diff --git a/lib/am/compile.am b/lib/am/compile.am
index 4ee20e1..9447bcc 100644
--- a/lib/am/compile.am
+++ b/lib/am/compile.am
@@ -27,6 +27,6 @@ else !%?STDINC%
 AM_DEFAULT_INCLUDES =
 endif !%?STDINC%
 
-am__mostlyclean_files += *.$(OBJEXT) %MOSTLY-CLEANED%
+am__mostlyclean_files += %MOSTLY-CLEANED%
 
 .PHONY: mostlyclean-compile
diff --git a/lib/am/libtool.am b/lib/am/libtool.am
index 34384a3..516f677 100644
--- a/lib/am/libtool.am
+++ b/lib/am/libtool.am
@@ -14,7 +14,6 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-am__mostlyclean_files += *.lo
 am__clean_dirs += %LIBTOOL-CLEAN-DIRECTORIES%
 
 ?TOPDIR_P?am__distclean_files += libtool config.lt
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]