From: Tom Tromey Date: Mon, 1 Jun 1998 21:12:08 +0000 (+0000) Subject: "clean" cleanup X-Git-Tag: Release-1-3b~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f2c1350af9d7653f1acd08ea37b9f7dce3817eb;p=thirdparty%2Fautomake.git "clean" cleanup --- diff --git a/ChangeLog b/ChangeLog index cb4983d9e..89ccbb522 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ Mon Jun 1 14:23:29 1998 Tom Tromey + * 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. diff --git a/Makefile.in b/Makefile.in index 53c4ec16a..f6ec9d2f4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 diff --git a/automake.in b/automake.in index 74fb984c5..88fd5948f 100755 --- a/automake.in +++ b/automake.in @@ -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 = (); diff --git a/clean.am b/clean.am index c89d2d3a4..9d8bebfe9 100644 --- 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 @@ -20,16 +20,15 @@ ## -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@ diff --git a/lib/am/clean.am b/lib/am/clean.am index c89d2d3a4..9d8bebfe9 100644 --- a/lib/am/clean.am +++ b/lib/am/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 @@ -20,16 +20,15 @@ ## -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@ diff --git a/m4/Makefile.in b/m4/Makefile.in index 1f6990ba4..a883fc896 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -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 diff --git a/tests/Makefile.in b/tests/Makefile.in index c77eb9a87..4d3650d47 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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