"clean" cleanup
authorTom Tromey <tromey@redhat.com>
Mon, 1 Jun 1998 21:12:08 +0000 (21:12 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 1 Jun 1998 21:12:08 +0000 (21:12 +0000)
ChangeLog
Makefile.in
automake.in
clean.am
lib/am/clean.am
m4/Makefile.in
tests/Makefile.in

index cb4983d..89ccbb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 Mon Jun  1 14:23:29 1998  Tom Tromey  <tromey@cygnus.com>
 
+       * clean.am (mostlyclean-generic): Prefix rule with MOSTLYCLEAN.
+       (clean-generic): Prefix rule with CLEAN.
+       (distclean-generic): Prefix rule with DISTCLEAN.
+       (maintainer-clean-generic): Prefix rule with MAINTAINERCLEAN.
+       BUILT_SOURCES now handled in automake itself.
+
+       * automake.in (initialize_per_input): Initialize
+       maintainer_clean_files.
+       (handle_yacc_lex_cxx): Put lex and yacc output files onto
+       @maintainer_clean_files.
+       (handle_clean): Handle @maintainer_clean_files.  Transform
+       clean.am when installing; try to remove unnecessary tests in
+       generated code.
+
        * automake.in (do_check_merge_target): Only generate $(MAKE)
        command if there are check targets to make.
 
index 53c4ec1..f6ec9d2 100644 (file)
@@ -32,7 +32,7 @@ mandir = @mandir@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DISTDIR =
+DESTDIR =
 
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -484,19 +484,14 @@ installdirs: installdirs-recursive
 
 
 mostlyclean-generic:
-       -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
 
 clean-generic:
-       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
-       -rm -f Makefile $(DISTCLEANFILES)
+       -rm -f Makefile $(CONFIG_CLEAN_FILES)
        -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
-       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 mostlyclean-am:  mostlyclean-vti mostlyclean-aminfo mostlyclean-tags \
                mostlyclean-generic
 
index 74fb984..88fd594 100755 (executable)
@@ -889,8 +889,11 @@ sub handle_yacc_lex_cxx
 
            # If the files are built in the build directory, then we
            # want to remove them with `make clean'.  If they are in
-           # srcdir they shouldn't be touched.
-           push (@clean, $base . $hname, $base . $cname);
+           # srcdir they shouldn't be touched.  However, we can't
+           # determine this statically, and the GNU rules say that
+           # yacc/lex output files should be removed by
+           # maintainer-clean.  So that's what we do.
+           push (@maintainer_clean_files, $base . $hname, $base . $cname);
        }
        $output_rules .= "\n";
 
@@ -917,10 +920,13 @@ sub handle_yacc_lex_cxx
 
            # If the files are built in the build directory, then we
            # want to remove them with `make clean'.  If they are in
-           # srcdir they shouldn't be touched.
+           # srcdir they shouldn't be touched.  However, we can't
+           # determine this statically, and the GNU rules say that
+           # yacc/lex output files should be removed by
+           # maintainer-clean.  So that's what we do.
            $file =~ /^(.*)\.(l|ll|l\+\+|lxx)$/;
            ($cname = $2) =~ tr/y/c/;
-           push (@clean, $1 . $cname);
+           push (@maintainer_clean_files, $1 . $cname);
        }
 
        if (! defined $configure_vars{'LEX'})
@@ -3677,8 +3683,46 @@ sub do_check_merge_target
 # Handle all 'clean' targets.
 sub handle_clean
 {
+    local ($xform) = '';
+    local ($name);
+
+    # Don't include `MAINTAINER'; it is handled specially below.
+    foreach $name ('MOSTLY', '', 'DIST')
+    {
+       if (! &variable_defined ($name . 'CLEANFILES'))
+       {
+           $xform .= 's/^' . $name . 'CLEAN.*$//;';
+       }
+       else
+       {
+           $xform .= 's/^' . $name . 'CLEAN//;';
+       }
+    }
+
+    # Built sources are automatically removed by maintainer-clean.
+    push (@maintainer_clean_files, '$(BUILT_SOURCES')
+       if &variable_defined ('BUILT_SOURCES');
+    push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
+       if &variable_defined ('MAINTAINERCLEANFILES');
+    if (! @maintainer_clean_files)
+    {
+       $xform .= 's/^MAINTAINERCLEAN.*$//;';
+    }
+    else
+    {
+       $xform .= ('s/^MAINTAINERCLEAN//;'
+                  # Join with no space to avoid spurious `test -z'
+                  # success at runtime.
+                  . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
+                  . ',;'
+                  # A space is required in the join here.
+                  . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
+                  . ',;');
+    }
+
+    $output_rules .= &file_contents_with_transform ($xform, 'clean');
+
     push (@clean, 'generic');
-    $output_rules .= &file_contents ('clean');
     &push_phony_cleaners ('generic');
 
     local ($target) = $recursive_install ? 'clean-am' : 'clean';
@@ -5569,6 +5613,9 @@ sub initialize_per_input
 
     @phony = ();
 
+    # A list of files deleted by `maintainer-clean'.
+    @maintainer_clean_files = ();
+
     # These are pretty obvious, too.  They are used to define the
     # SOURCES and OBJECTS variables.
     @sources = ();
index c89d2d3..9d8bebf 100644 (file)
--- a/clean.am
+++ b/clean.am
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+## Copyright (C) 1994, 1995, 1996, 1998 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
 ## -rf" command looks disturbing.  Also, the Solaris 2.4 "rm" will
 ## return an error if there are no arguments other than "-f".
 mostlyclean-generic:
-       -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+MOSTLYCLEAN    -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
 
 clean-generic:
-       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+CLEAN  -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
-       -rm -f Makefile $(DISTCLEANFILES)
+       -rm -f Makefile $(CONFIG_CLEAN_FILES)
        -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+DISTCLEAN      -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCONFIGCLEANFILES)
 
 maintainer-clean-generic:
-       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+MAINTAINERCLEAN        -test -z "@MCFILES@" || rm -f @MFILES@
index c89d2d3..9d8bebf 100644 (file)
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+## Copyright (C) 1994, 1995, 1996, 1998 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
 ## -rf" command looks disturbing.  Also, the Solaris 2.4 "rm" will
 ## return an error if there are no arguments other than "-f".
 mostlyclean-generic:
-       -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+MOSTLYCLEAN    -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
 
 clean-generic:
-       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+CLEAN  -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
-       -rm -f Makefile $(DISTCLEANFILES)
+       -rm -f Makefile $(CONFIG_CLEAN_FILES)
        -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+DISTCLEAN      -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCONFIGCLEANFILES)
 
 maintainer-clean-generic:
-       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+MAINTAINERCLEAN        -test -z "@MCFILES@" || rm -f @MFILES@
index 1f6990b..a883fc8 100644 (file)
@@ -32,7 +32,7 @@ mandir = @mandir@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DISTDIR =
+DESTDIR =
 
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -135,7 +135,6 @@ distdir: $(DISTFILES)
 info:
 dvi:
 check: all
-       $(MAKE)
 installcheck:
 install-exec: 
        @$(NORMAL_INSTALL)
@@ -155,19 +154,14 @@ installdirs:
 
 
 mostlyclean-generic:
-       -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
 
 clean-generic:
-       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
-       -rm -f Makefile $(DISTCLEANFILES)
+       -rm -f Makefile $(CONFIG_CLEAN_FILES)
        -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
-       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 mostlyclean:  mostlyclean-generic
 
 clean:  clean-generic mostlyclean
index c77eb9a..4d3650d 100644 (file)
@@ -32,7 +32,7 @@ mandir = @mandir@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DISTDIR =
+DESTDIR =
 
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -182,19 +182,14 @@ installdirs:
 
 
 mostlyclean-generic:
-       -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
 
 clean-generic:
-       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
-       -rm -f Makefile $(DISTCLEANFILES)
+       -rm -f Makefile $(CONFIG_CLEAN_FILES)
        -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
-       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 mostlyclean:  mostlyclean-generic
 
 clean:  clean-generic mostlyclean